diff --git a/administrator/components/com_messages/Model/MessageModel.php b/administrator/components/com_messages/Model/MessageModel.php index 535f56b4ef09a..11dadf201fe1c 100644 --- a/administrator/components/com_messages/Model/MessageModel.php +++ b/administrator/components/com_messages/Model/MessageModel.php @@ -11,6 +11,8 @@ defined('_JEXEC') or die; +use Joomla\CMS\Access\Access; +use Joomla\CMS\Access\Rule; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Language\Language; @@ -18,7 +20,8 @@ use Joomla\CMS\Log\Log; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Router\Route; -use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Table\Asset; +use Joomla\CMS\Table\Table; use Joomla\CMS\User\User; /** @@ -446,17 +449,17 @@ public function notifySuperUsers($subject, $message, $fromUser = null) try { - /** @var JTableAsset $table */ - $table = $this->getTable('Asset', 'JTable'); + /** @var Asset $table */ + $table = Table::getInstance('Asset'); $rootId = $table->getRootId(); - /** @var JAccessRule[] $rules */ - $rules = JAccess::getAssetRules($rootId)->getData(); + /** @var Rule[] $rules */ + $rules = Access::getAssetRules($rootId)->getData(); $rawGroups = $rules['core.admin']->getData(); if (empty($rawGroups)) { - $this->setError(JText::_('COM_MESSAGES_ERROR_MISSING_ROOT_ASSET_GROUPS')); + $this->setError(Text::_('COM_MESSAGES_ERROR_MISSING_ROOT_ASSET_GROUPS')); return false; } @@ -473,7 +476,7 @@ public function notifySuperUsers($subject, $message, $fromUser = null) if (empty($groups)) { - $this->setError(JText::_('COM_MESSAGES_ERROR_NO_GROUPS_SET_AS_SUPER_USER')); + $this->setError(Text::_('COM_MESSAGES_ERROR_NO_GROUPS_SET_AS_SUPER_USER')); return false; } @@ -487,7 +490,7 @@ public function notifySuperUsers($subject, $message, $fromUser = null) if (empty($userIDs)) { - $this->setError(JText::_('COM_MESSAGES_ERROR_NO_USERS_SET_AS_SUPER_USER')); + $this->setError(Text::_('COM_MESSAGES_ERROR_NO_USERS_SET_AS_SUPER_USER')); return false; } @@ -498,12 +501,12 @@ public function notifySuperUsers($subject, $message, $fromUser = null) * All messages must have a valid from user, we have use cases where an unauthenticated user may trigger this * so we will set the from user as the to user */ - $data = array( + $data = [ 'user_id_from' => $id, 'user_id_to' => $id, 'subject' => $subject, 'message' => $message, - ); + ]; if (!$this->save($data)) { @@ -513,7 +516,7 @@ public function notifySuperUsers($subject, $message, $fromUser = null) return true; } - catch (Exception $exception) + catch (\Exception $exception) { $this->setError($exception->getMessage()); diff --git a/administrator/components/com_privacy/controllers/consents.php b/administrator/components/com_privacy/Controller/ConsentsController.php similarity index 56% rename from administrator/components/com_privacy/controllers/consents.php rename to administrator/components/com_privacy/Controller/ConsentsController.php index be31a6579ab50..9bbbab4838e89 100644 --- a/administrator/components/com_privacy/controllers/consents.php +++ b/administrator/components/com_privacy/Controller/ConsentsController.php @@ -7,14 +7,21 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Controller; + defined('_JEXEC') or die; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\Router\Route; +use Joomla\Component\Privacy\Administrator\Model\ConsentsModel; + /** * Consents management controller class. * * @since 3.9.0 */ -class PrivacyControllerConsents extends JControllerForm +class ConsentsController extends FormController { /** * Method to invalidate specific consents. @@ -26,18 +33,18 @@ class PrivacyControllerConsents extends JControllerForm public function invalidate($key = null, $urlVar = null) { // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + $this->checkToken(); - $ids = $this->input->get('cid', array(), 'array'); + $ids = $this->input->get('cid', [], 'array'); if (empty($ids)) { - $this->setError(JText::_('JERROR_NO_ITEMS_SELECTED')); + $this->setError(Text::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. - /** @var PrivacyModelConsents $model */ + /** @var ConsentsModel $model */ $model = $this->getModel(); // Publish the items. @@ -46,10 +53,10 @@ public function invalidate($key = null, $urlVar = null) $this->setError($model->getError()); } - $message = JText::plural('COM_PRIVACY_N_CONSENTS_INVALIDATED', count($ids)); + $message = Text::plural('COM_PRIVACY_N_CONSENTS_INVALIDATED', count($ids)); } - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=consents', false), $message); + $this->setRedirect(Route::_('index.php?option=com_privacy&view=consents', false), $message); } /** @@ -62,9 +69,9 @@ public function invalidate($key = null, $urlVar = null) public function invalidateAll() { // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + $this->checkToken(); - $filters = $this->input->get('filter', array(), 'array'); + $filters = $this->input->get('filter', [], 'array'); if (isset($filters['subject']) && $filters['subject'] != '') { @@ -72,11 +79,11 @@ public function invalidateAll() } else { - $this->setError(JText::_('JERROR_NO_ITEMS_SELECTED')); + $this->setError(Text::_('JERROR_NO_ITEMS_SELECTED')); } // Get the model. - /** @var PrivacyModelConsents $model */ + /** @var ConsentsModel $model */ $model = $this->getModel(); // Publish the items. @@ -85,8 +92,8 @@ public function invalidateAll() $this->setError($model->getError()); } - $message = JText::_('COM_PRIVACY_CONSENTS_INVALIDATED_ALL'); + $message = Text::_('COM_PRIVACY_CONSENTS_INVALIDATED_ALL'); - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=consents', false), $message); + $this->setRedirect(Route::_('index.php?option=com_privacy&view=consents', false), $message); } } diff --git a/administrator/components/com_privacy/controller.php b/administrator/components/com_privacy/Controller/DisplayController.php similarity index 71% rename from administrator/components/com_privacy/controller.php rename to administrator/components/com_privacy/Controller/DisplayController.php index 0c902d65b42b0..bac4d5d39c611 100644 --- a/administrator/components/com_privacy/controller.php +++ b/administrator/components/com_privacy/Controller/DisplayController.php @@ -7,19 +7,26 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Controller; + defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\CMS\Response\JsonResponse; +use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use Joomla\Component\Privacy\Administrator\Helper\PrivacyHelper; +use Joomla\Component\Privacy\Administrator\Model\RequestsModel; /** * Privacy Controller * * @since 3.9.0 */ -class PrivacyController extends JControllerLegacy +class DisplayController extends BaseController { /** * The default view. @@ -39,12 +46,10 @@ class PrivacyController extends JControllerLegacy * * @since 3.9.0 */ - public function display($cachable = false, $urlparams = array()) + public function display($cachable = false, $urlparams = []) { - JLoader::register('PrivacyHelper', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/privacy.php'); - // Get the document object. - $document = JFactory::getDocument(); + $document = Factory::getDocument(); // Set the default view name and format from the Request. $vName = $this->input->get('view', $this->default_view); @@ -70,10 +75,10 @@ public function display($cachable = false, $urlparams = array()) // For the default layout, we need to also push the action logs model into the view if ($lName === 'default') { - JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php'); - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + \JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php'); + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - $logsModel = $this->getModel('Actionlogs', 'ActionlogsModel'); + $logsModel = BaseDatabaseModel::getInstance('Actionlogs', 'ActionlogsModel'); // Set default ordering for the context $logsModel->setState('list.fullordering', 'a.log_date DESC'); @@ -83,11 +88,11 @@ public function display($cachable = false, $urlparams = array()) } // For the edit layout, if mail sending is disabled then redirect back to the list view as the form is unusable in this state - if ($lName === 'edit' && !JFactory::getConfig()->get('mailonline', 1)) + if ($lName === 'edit' && !Factory::getConfig()->get('mailonline', 1)) { $this->setRedirect( - JRoute::_('index.php?option=com_privacy&view=requests', false), - JText::_('COM_PRIVACY_WARNING_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED'), + Route::_('index.php?option=com_privacy&view=requests', false), + Text::_('COM_PRIVACY_WARNING_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED'), 'warning' ); @@ -112,9 +117,9 @@ public function display($cachable = false, $urlparams = array()) /** * Fetch and report number urgent privacy requests in JSON format, for AJAX requests * - * @return void + * @return void * - * @since 3.9.0 + * @since 3.9.0 */ public function getNumberUrgentRequests() { @@ -129,12 +134,10 @@ public function getNumberUrgentRequests() $app->close(); } - /** @var PrivacyModelRequests $model */ + /** @var RequestsModel $model */ $model = $this->getModel('requests'); $numberUrgentRequests = $model->getNumberUrgentRequests(); - echo new JResponseJson(array('number_urgent_requests' => $numberUrgentRequests)); - - $app->close(); + echo new JsonResponse(['number_urgent_requests' => $numberUrgentRequests]); } } diff --git a/administrator/components/com_privacy/controllers/request.php b/administrator/components/com_privacy/Controller/RequestController.php similarity index 71% rename from administrator/components/com_privacy/controllers/request.php rename to administrator/components/com_privacy/Controller/RequestController.php index 2857ed40d2619..dc794282a78bb 100644 --- a/administrator/components/com_privacy/controllers/request.php +++ b/administrator/components/com_privacy/Controller/RequestController.php @@ -7,14 +7,27 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Controller; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Uri\Uri; +use Joomla\Component\Privacy\Administrator\Model\ExportModel; +use Joomla\Component\Privacy\Administrator\Model\RemoveModel; +use Joomla\Component\Privacy\Administrator\Model\RequestModel; +use Joomla\Component\Privacy\Administrator\Table\RequestTable; + /** * Request management controller class. * * @since 3.9.0 */ -class PrivacyControllerRequest extends JControllerForm +class RequestController extends FormController { /** * Method to complete a request. @@ -29,12 +42,12 @@ class PrivacyControllerRequest extends JControllerForm public function complete($key = null, $urlVar = null) { // Check for request forgeries. - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + $this->checkToken(); - /** @var PrivacyModelRequest $model */ + /** @var RequestModel $model */ $model = $this->getModel(); - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $model->getTable(); // Determine the name of the primary key for the data. @@ -56,11 +69,11 @@ public function complete($key = null, $urlVar = null) // Ensure this record can transition to the requested state if (!$this->canTransition($item, '2')) { - $this->setError(\JText::_('COM_PRIVACY_ERROR_COMPLETE_TRANSITION_NOT_PERMITTED')); + $this->setError(Text::_('COM_PRIVACY_ERROR_COMPLETE_TRANSITION_NOT_PERMITTED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect( - \JRoute::_( + Route::_( 'index.php?option=com_privacy&view=request&id=' . $recordId, false ) ); @@ -69,19 +82,19 @@ public function complete($key = null, $urlVar = null) } // Build the data array for the update - $data = array( + $data = [ $key => $recordId, 'status' => '2', - ); + ]; // Access check. if (!$this->allowSave($data, $key)) { - $this->setError(\JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); + $this->setError(Text::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect( - \JRoute::_( + Route::_( 'index.php?option=com_privacy&view=request&id=' . $recordId, false ) ); @@ -93,11 +106,11 @@ public function complete($key = null, $urlVar = null) if (!$model->save($data)) { // Redirect back to the edit screen. - $this->setError(\JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); $this->setMessage($this->getError(), 'error'); $this->setRedirect( - \JRoute::_( + Route::_( 'index.php?option=com_privacy&view=request&id=' . $recordId, false ) ); @@ -108,20 +121,20 @@ public function complete($key = null, $urlVar = null) // Log the request completed $model->logRequestCompleted($recordId); - $this->setMessage(\JText::_('COM_PRIVACY_REQUEST_COMPLETED')); + $this->setMessage(Text::_('COM_PRIVACY_REQUEST_COMPLETED')); $url = 'index.php?option=com_privacy&view=requests'; // Check if there is a return value $return = $this->input->get('return', null, 'base64'); - if (!is_null($return) && \JUri::isInternal(base64_decode($return))) + if (!is_null($return) && Uri::isInternal(base64_decode($return))) { $url = base64_decode($return); } // Redirect to the list screen. - $this->setRedirect(\JRoute::_($url, false)); + $this->setRedirect(Route::_($url, false)); return true; } @@ -135,7 +148,7 @@ public function complete($key = null, $urlVar = null) */ public function emailexport() { - /** @var PrivacyModelExport $model */ + /** @var ExportModel $model */ $model = $this->getModel('Export'); $recordId = $this->input->getUint('id'); @@ -143,12 +156,12 @@ public function emailexport() if (!$model->emailDataExport($recordId)) { // Redirect back to the edit screen. - $this->setError(\JText::sprintf('COM_PRIVACY_ERROR_EXPORT_EMAIL_FAILED', $model->getError())); + $this->setError(Text::sprintf('COM_PRIVACY_ERROR_EXPORT_EMAIL_FAILED', $model->getError())); $this->setMessage($this->getError(), 'error'); } else { - $this->setMessage(\JText::_('COM_PRIVACY_EXPORT_EMAILED')); + $this->setMessage(Text::_('COM_PRIVACY_EXPORT_EMAILED')); } $url = 'index.php?option=com_privacy&view=requests'; @@ -156,17 +169,31 @@ public function emailexport() // Check if there is a return value $return = $this->input->get('return', null, 'base64'); - if (!is_null($return) && \JUri::isInternal(base64_decode($return))) + if (!is_null($return) && Uri::isInternal(base64_decode($return))) { $url = base64_decode($return); } // Redirect to the list screen. - $this->setRedirect(\JRoute::_($url, false)); + $this->setRedirect(Route::_($url, false)); return true; } + /** + * Method to export the data for a request. + * + * @return $this + * + * @since 3.9.0 + */ + public function export() + { + $this->input->set('view', 'export'); + + return $this->display(); + } + /** * Method to invalidate a request. * @@ -180,7 +207,7 @@ public function emailexport() public function invalidate($key = null, $urlVar = null) { // Check for request forgeries. - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + $this->checkToken(); /** @var PrivacyModelRequest $model */ $model = $this->getModel(); @@ -207,11 +234,11 @@ public function invalidate($key = null, $urlVar = null) // Ensure this record can transition to the requested state if (!$this->canTransition($item, '-1')) { - $this->setError(\JText::_('COM_PRIVACY_ERROR_INVALID_TRANSITION_NOT_PERMITTED')); + $this->setError(Text::_('COM_PRIVACY_ERROR_INVALID_TRANSITION_NOT_PERMITTED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect( - \JRoute::_( + Route::_( 'index.php?option=com_privacy&view=request&id=' . $recordId, false ) ); @@ -220,19 +247,19 @@ public function invalidate($key = null, $urlVar = null) } // Build the data array for the update - $data = array( + $data = [ $key => $recordId, 'status' => '-1', - ); + ]; // Access check. if (!$this->allowSave($data, $key)) { - $this->setError(\JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); + $this->setError(Text::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect( - \JRoute::_( + Route::_( 'index.php?option=com_privacy&view=request&id=' . $recordId, false ) ); @@ -244,11 +271,11 @@ public function invalidate($key = null, $urlVar = null) if (!$model->save($data)) { // Redirect back to the edit screen. - $this->setError(\JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); $this->setMessage($this->getError(), 'error'); $this->setRedirect( - \JRoute::_( + Route::_( 'index.php?option=com_privacy&view=request&id=' . $recordId, false ) ); @@ -259,20 +286,20 @@ public function invalidate($key = null, $urlVar = null) // Log the request invalidated $model->logRequestInvalidated($recordId); - $this->setMessage(\JText::_('COM_PRIVACY_REQUEST_INVALIDATED')); + $this->setMessage(Text::_('COM_PRIVACY_REQUEST_INVALIDATED')); $url = 'index.php?option=com_privacy&view=requests'; // Check if there is a return value $return = $this->input->get('return', null, 'base64'); - if (!is_null($return) && \JUri::isInternal(base64_decode($return))) + if (!is_null($return) && Uri::isInternal(base64_decode($return))) { $url = base64_decode($return); } // Redirect to the list screen. - $this->setRedirect(\JRoute::_($url, false)); + $this->setRedirect(Route::_($url, false)); return true; } @@ -286,7 +313,7 @@ public function invalidate($key = null, $urlVar = null) */ public function remove() { - /** @var PrivacyModelRemove $model */ + /** @var RemoveModel $model */ $model = $this->getModel('Remove'); $recordId = $this->input->getUint('id'); @@ -294,11 +321,11 @@ public function remove() if (!$model->removeDataForRequest($recordId)) { // Redirect back to the edit screen. - $this->setError(\JText::sprintf('COM_PRIVACY_ERROR_REMOVE_DATA_FAILED', $model->getError())); + $this->setError(Text::sprintf('COM_PRIVACY_ERROR_REMOVE_DATA_FAILED', $model->getError())); $this->setMessage($this->getError(), 'error'); $this->setRedirect( - \JRoute::_( + Route::_( 'index.php?option=com_privacy&view=request&id=' . $recordId, false ) ); @@ -306,20 +333,20 @@ public function remove() return false; } - $this->setMessage(\JText::_('COM_PRIVACY_DATA_REMOVED')); + $this->setMessage(Text::_('COM_PRIVACY_DATA_REMOVED')); $url = 'index.php?option=com_privacy&view=requests'; // Check if there is a return value $return = $this->input->get('return', null, 'base64'); - if (!is_null($return) && \JUri::isInternal(base64_decode($return))) + if (!is_null($return) && Uri::isInternal(base64_decode($return))) { $url = base64_decode($return); } // Redirect to the list screen. - $this->setRedirect(\JRoute::_($url, false)); + $this->setRedirect(Route::_($url, false)); return true; } @@ -327,14 +354,14 @@ public function remove() /** * Function that allows child controller access to model data after the data has been saved. * - * @param \JModelLegacy $model The data model object. - * @param array $validData The validated data. + * @param BaseDatabaseModel $model The data model object. + * @param array $validData The validated data. * * @return void * * @since 3.9.0 */ - protected function postSaveHook(\JModelLegacy $model, $validData = array()) + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) { // This hook only processes new items if (!$model->getState($model->getName() . '.new', false)) @@ -346,7 +373,7 @@ protected function postSaveHook(\JModelLegacy $model, $validData = array()) { if ($error = $model->getError()) { - JFactory::getApplication()->enqueueMessage($error, 'warning'); + Factory::getApplication()->enqueueMessage($error, 'warning'); } } @@ -354,12 +381,12 @@ protected function postSaveHook(\JModelLegacy $model, $validData = array()) { if ($error = $model->getError()) { - JFactory::getApplication()->enqueueMessage($error, 'warning'); + Factory::getApplication()->enqueueMessage($error, 'warning'); } } else { - JFactory::getApplication()->enqueueMessage(JText::_('COM_PRIVACY_MSG_CONFIRM_EMAIL_SENT_TO_USER')); + Factory::getApplication()->enqueueMessage(Text::_('COM_PRIVACY_MSG_CONFIRM_EMAIL_SENT_TO_USER')); } } @@ -383,7 +410,7 @@ private function canTransition($item, $newStatus) case '1': // A confirmed item can be marked completed or invalid - return in_array($newStatus, array('-1', '2'), true); + return in_array($newStatus, ['-1', '2'], true); // An item which is already in an invalid or complete state cannot transition, likewise if we don't know the state don't change anything case '-1': diff --git a/administrator/components/com_privacy/controllers/requests.php b/administrator/components/com_privacy/Controller/RequestsController.php similarity index 63% rename from administrator/components/com_privacy/controllers/requests.php rename to administrator/components/com_privacy/Controller/RequestsController.php index abcc7f38eece0..a0d88ca4988ad 100644 --- a/administrator/components/com_privacy/controllers/requests.php +++ b/administrator/components/com_privacy/Controller/RequestsController.php @@ -7,14 +7,19 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Controller; + defined('_JEXEC') or die; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; + /** * Requests management controller class. * * @since 3.9.0 */ -class PrivacyControllerRequests extends JControllerAdmin +class RequestsController extends AdminController { /** * Method to get a model object, loading it if required. @@ -23,11 +28,11 @@ class PrivacyControllerRequests extends JControllerAdmin * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * - * @return JModelLegacy|boolean Model object on success; otherwise false on failure. + * @return BaseDatabaseModel|boolean Model object on success; otherwise false on failure. * * @since 3.9.0 */ - public function getModel($name = 'Request', $prefix = 'PrivacyModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Request', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/administrator/components/com_privacy/Dispatcher/Dispatcher.php b/administrator/components/com_privacy/Dispatcher/Dispatcher.php new file mode 100644 index 0000000000000..8fd83c861ac7e --- /dev/null +++ b/administrator/components/com_privacy/Dispatcher/Dispatcher.php @@ -0,0 +1,37 @@ +app->isClient('administrator') && !$this->app->getIdentity()->authorise('core.admin', $this->option)) + { + throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403); + } + } +} diff --git a/administrator/components/com_privacy/helpers/export/domain.php b/administrator/components/com_privacy/Export/Domain.php similarity index 75% rename from administrator/components/com_privacy/helpers/export/domain.php rename to administrator/components/com_privacy/Export/Domain.php index 198d896611d45..d6098c9925c08 100644 --- a/administrator/components/com_privacy/helpers/export/domain.php +++ b/administrator/components/com_privacy/Export/Domain.php @@ -7,9 +7,9 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -defined('_JEXEC') or die; +namespace Joomla\Component\Privacy\Administrator\Export; -JLoader::register('PrivacyExportItem', __DIR__ . '/item.php'); +defined('_JEXEC') or die; /** * Data object representing all data contained in a domain. @@ -18,7 +18,7 @@ * * @since 3.9.0 */ -class PrivacyExportDomain +class Domain { /** * The name of this domain @@ -39,21 +39,21 @@ class PrivacyExportDomain /** * The items belonging to this domain * - * @var PrivacyExportItem[] + * @var Item[] * @since 3.9.0 */ - protected $items = array(); + protected $items = []; /** * Add an item to the domain * - * @param PrivacyExportItem $item The item to add + * @param Item $item The item to add * * @return void * - * @since 3.9.0 + * @since 3.9.0 */ - public function addItem(PrivacyExportItem $item) + public function addItem(Item $item) { $this->items[] = $item; } @@ -61,9 +61,9 @@ public function addItem(PrivacyExportItem $item) /** * Get the domain's items * - * @return PrivacyExportItem[] + * @return Item[] * - * @since 3.9.0 + * @since 3.9.0 */ public function getItems() { diff --git a/administrator/components/com_privacy/helpers/export/field.php b/administrator/components/com_privacy/Export/Field.php similarity index 88% rename from administrator/components/com_privacy/helpers/export/field.php rename to administrator/components/com_privacy/Export/Field.php index 9d020736bf871..0a057e5d5b503 100644 --- a/administrator/components/com_privacy/helpers/export/field.php +++ b/administrator/components/com_privacy/Export/Field.php @@ -7,6 +7,8 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Export; + defined('_JEXEC') or die; /** @@ -14,7 +16,7 @@ * * @since 3.9.0 */ -class PrivacyExportField +class Field { /** * The name of this field diff --git a/administrator/components/com_privacy/helpers/export/item.php b/administrator/components/com_privacy/Export/Item.php similarity index 72% rename from administrator/components/com_privacy/helpers/export/item.php rename to administrator/components/com_privacy/Export/Item.php index e1f94cf8aba59..1755125ab866c 100644 --- a/administrator/components/com_privacy/helpers/export/item.php +++ b/administrator/components/com_privacy/Export/Item.php @@ -7,9 +7,9 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -defined('_JEXEC') or die; +namespace Joomla\Component\Privacy\Administrator\Export; -JLoader::register('PrivacyExportField', __DIR__ . '/field.php'); +defined('_JEXEC') or die; /** * Data object representing a single item within a domain. @@ -18,7 +18,7 @@ * * @since 3.9.0 */ -class PrivacyExportItem +class Item { /** * The primary identifier of this item, typically the primary key for a database row. @@ -31,21 +31,21 @@ class PrivacyExportItem /** * The fields belonging to this item * - * @var PrivacyExportField[] + * @var Field[] * @since 3.9.0 */ - protected $fields = array(); + protected $fields = []; /** * Add a field to the item * - * @param PrivacyExportField $field The field to add + * @param Field $field The field to add * * @return void * - * @since 3.9.0 + * @since 3.9.0 */ - public function addField(PrivacyExportField $field) + public function addField(Field $field) { $this->fields[] = $field; } @@ -53,9 +53,9 @@ public function addField(PrivacyExportField $field) /** * Get the item's fields * - * @return PrivacyExportField[] + * @return Field[] * - * @since 3.9.0 + * @since 3.9.0 */ public function getFields() { diff --git a/administrator/components/com_privacy/Extension/PrivacyComponent.php b/administrator/components/com_privacy/Extension/PrivacyComponent.php new file mode 100644 index 0000000000000..e7498bd67467d --- /dev/null +++ b/administrator/components/com_privacy/Extension/PrivacyComponent.php @@ -0,0 +1,46 @@ +getRegistry()->register('privacy', new Privacy); + } +} diff --git a/administrator/components/com_privacy/models/fields/requeststatus.php b/administrator/components/com_privacy/Field/RequeststatusField.php similarity index 78% rename from administrator/components/com_privacy/models/fields/requeststatus.php rename to administrator/components/com_privacy/Field/RequeststatusField.php index 16a9b4422dbe6..9bf464d3b5c32 100644 --- a/administrator/components/com_privacy/models/fields/requeststatus.php +++ b/administrator/components/com_privacy/Field/RequeststatusField.php @@ -7,16 +7,18 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Field; + defined('_JEXEC') or die; -JFormHelper::loadFieldClass('predefinedlist'); +use Joomla\CMS\Form\Field\PredefinedlistField; /** * Form Field to load a list of request statuses * * @since 3.9.0 */ -class PrivacyFormFieldRequeststatus extends JFormFieldPredefinedList +class RequeststatusField extends PredefinedlistField { /** * The form field type. @@ -32,10 +34,10 @@ class PrivacyFormFieldRequeststatus extends JFormFieldPredefinedList * @var array * @since 3.9.0 */ - protected $predefinedOptions = array( + protected $predefinedOptions = [ '-1' => 'COM_PRIVACY_STATUS_INVALID', '0' => 'COM_PRIVACY_STATUS_PENDING', '1' => 'COM_PRIVACY_STATUS_CONFIRMED', '2' => 'COM_PRIVACY_STATUS_COMPLETED', - ); + ]; } diff --git a/administrator/components/com_privacy/models/fields/requesttype.php b/administrator/components/com_privacy/Field/RequesttypeField.php similarity index 77% rename from administrator/components/com_privacy/models/fields/requesttype.php rename to administrator/components/com_privacy/Field/RequesttypeField.php index 8ceb10c9784e8..23aeea5692558 100644 --- a/administrator/components/com_privacy/models/fields/requesttype.php +++ b/administrator/components/com_privacy/Field/RequesttypeField.php @@ -7,16 +7,18 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -defined('_JEXEC') or die; +namespace Joomla\Component\Privacy\Administrator\Field; + +use Joomla\CMS\Form\Field\PredefinedlistField; -JFormHelper::loadFieldClass('predefinedlist'); +defined('_JEXEC') or die; /** * Form Field to load a list of request types * * @since 3.9.0 */ -class PrivacyFormFieldRequesttype extends JFormFieldPredefinedList +class RequesttypeField extends PredefinedlistField { /** * The form field type. @@ -32,8 +34,8 @@ class PrivacyFormFieldRequesttype extends JFormFieldPredefinedList * @var array * @since 3.9.0 */ - protected $predefinedOptions = array( + protected $predefinedOptions = [ 'export' => 'COM_PRIVACY_HEADING_REQUEST_TYPE_TYPE_EXPORT', 'remove' => 'COM_PRIVACY_HEADING_REQUEST_TYPE_TYPE_REMOVE', - ); + ]; } diff --git a/administrator/components/com_privacy/helpers/privacy.php b/administrator/components/com_privacy/Helper/PrivacyHelper.php similarity index 69% rename from administrator/components/com_privacy/helpers/privacy.php rename to administrator/components/com_privacy/Helper/PrivacyHelper.php index 806f9b4c318f3..2265bac27af43 100644 --- a/administrator/components/com_privacy/helpers/privacy.php +++ b/administrator/components/com_privacy/Helper/PrivacyHelper.php @@ -7,14 +7,20 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Helper; + defined('_JEXEC') or die; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\Component\Privacy\Administrator\Export\Domain; + /** * Privacy component helper. * * @since 3.9.0 */ -class PrivacyHelper extends JHelperContent +class PrivacyHelper extends ContentHelper { /** * Configure the Linkbar. @@ -27,26 +33,26 @@ class PrivacyHelper extends JHelperContent */ public static function addSubmenu($vName) { - JHtmlSidebar::addEntry( - JText::_('COM_PRIVACY_SUBMENU_DASHBOARD'), + \JHtmlSidebar::addEntry( + Text::_('COM_PRIVACY_SUBMENU_DASHBOARD'), 'index.php?option=com_privacy&view=dashboard', $vName === 'dashboard' ); - JHtmlSidebar::addEntry( - JText::_('COM_PRIVACY_SUBMENU_REQUESTS'), + \JHtmlSidebar::addEntry( + Text::_('COM_PRIVACY_SUBMENU_REQUESTS'), 'index.php?option=com_privacy&view=requests', $vName === 'requests' ); - JHtmlSidebar::addEntry( - JText::_('COM_PRIVACY_SUBMENU_CAPABILITIES'), + \JHtmlSidebar::addEntry( + Text::_('COM_PRIVACY_SUBMENU_CAPABILITIES'), 'index.php?option=com_privacy&view=capabilities', $vName === 'capabilities' ); - JHtmlSidebar::addEntry( - JText::_('COM_PRIVACY_SUBMENU_CONSENTS'), + \JHtmlSidebar::addEntry( + Text::_('COM_PRIVACY_SUBMENU_CONSENTS'), 'index.php?option=com_privacy&view=consents', $vName === 'consents' ); @@ -55,7 +61,7 @@ public static function addSubmenu($vName) /** * Render the data request as a XML document. * - * @param PrivacyExportDomain[] $exportData The data to be exported. + * @param Domain[] $exportData The data to be exported. * * @return string * @@ -63,7 +69,7 @@ public static function addSubmenu($vName) */ public static function renderDataAsXml(array $exportData) { - $export = new SimpleXMLElement(''); + $export = new \SimpleXMLElement(''); foreach ($exportData as $domain) { @@ -87,7 +93,7 @@ public static function renderDataAsXml(array $exportData) } } - $dom = new DOMDocument; + $dom = new \DOMDocument; $dom->loadXML($export->asXML()); $dom->formatOutput = true; diff --git a/administrator/components/com_privacy/models/capabilities.php b/administrator/components/com_privacy/Model/CapabilitiesModel.php similarity index 69% rename from administrator/components/com_privacy/models/capabilities.php rename to administrator/components/com_privacy/Model/CapabilitiesModel.php index 0e7e836f777be..85d68209ddbee 100644 --- a/administrator/components/com_privacy/models/capabilities.php +++ b/administrator/components/com_privacy/Model/CapabilitiesModel.php @@ -7,14 +7,22 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Model; + defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\BaseModel; +use Joomla\CMS\Plugin\PluginHelper; + /** * Capabilities model class. * * @since 3.9.0 */ -class PrivacyModelCapabilities extends JModelLegacy +class CapabilitiesModel extends BaseModel { /** * Retrieve the extension capabilities. @@ -25,7 +33,7 @@ class PrivacyModelCapabilities extends JModelLegacy */ public function getCapabilities() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); /* * Capabilities will be collected in two parts: @@ -39,13 +47,13 @@ public function getCapabilities() * $coreCapabilities array below. */ - $coreCapabilities = array( - JText::_('COM_PRIVACY_HEADING_CORE_CAPABILITIES') => array( - JText::_('COM_PRIVACY_CORE_CAPABILITY_SESSION_IP_ADDRESS_AND_COOKIE'), - JText::sprintf('COM_PRIVACY_CORE_CAPABILITY_LOGGING_IP_ADDRESS', $app->get('log_path', JPATH_ADMINISTRATOR . '/logs')), - JText::_('COM_PRIVACY_CORE_CAPABILITY_COMMUNICATION_WITH_JOOMLA_ORG'), - ) - ); + $coreCapabilities = [ + Text::_('COM_PRIVACY_HEADING_CORE_CAPABILITIES') => [ + Text::_('COM_PRIVACY_CORE_CAPABILITY_SESSION_IP_ADDRESS_AND_COOKIE'), + Text::sprintf('COM_PRIVACY_CORE_CAPABILITY_LOGGING_IP_ADDRESS', $app->get('log_path', JPATH_ADMINISTRATOR . '/logs')), + Text::_('COM_PRIVACY_CORE_CAPABILITY_COMMUNICATION_WITH_JOOMLA_ORG'), + ], + ]; /* * We will search for capabilities from the following plugin groups: @@ -59,20 +67,20 @@ public function getCapabilities() * This is in addition to plugin groups which are imported before this method is triggered, generally this is the system group. */ - JPluginHelper::importPlugin('authentication'); - JPluginHelper::importPlugin('captcha'); - JPluginHelper::importPlugin('installer'); - JPluginHelper::importPlugin('privacy'); - JPluginHelper::importPlugin('user'); + PluginHelper::importPlugin('authentication'); + PluginHelper::importPlugin('captcha'); + PluginHelper::importPlugin('installer'); + PluginHelper::importPlugin('privacy'); + PluginHelper::importPlugin('user'); $pluginResults = $app->triggerEvent('onPrivacyCollectAdminCapabilities'); // We are going to "cheat" here and include this component's capabilities without using a plugin - $extensionCapabilities = array( - JText::_('COM_PRIVACY') => array( - JText::_('COM_PRIVACY_EXTENSION_CAPABILITY_PERSONAL_INFO'), - ) - ); + $extensionCapabilities = [ + Text::_('COM_PRIVACY') => [ + Text::_('COM_PRIVACY_EXTENSION_CAPABILITY_PERSONAL_INFO'), + ], + ]; foreach ($pluginResults as $pluginResult) { @@ -96,6 +104,6 @@ public function getCapabilities() protected function populateState() { // Load the parameters. - $this->setState('params', JComponentHelper::getParams('com_privacy')); + $this->setState('params', ComponentHelper::getParams('com_privacy')); } } diff --git a/administrator/components/com_privacy/models/consents.php b/administrator/components/com_privacy/Model/ConsentsModel.php similarity index 88% rename from administrator/components/com_privacy/models/consents.php rename to administrator/components/com_privacy/Model/ConsentsModel.php index 1a345e382fa89..0a4274e08b9ef 100644 --- a/administrator/components/com_privacy/models/consents.php +++ b/administrator/components/com_privacy/Model/ConsentsModel.php @@ -7,8 +7,14 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Model; + defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Database\DatabaseQuery; +use Joomla\Database\Exception\ExecutionFailureException; use Joomla\Utilities\ArrayHelper; /** @@ -16,7 +22,7 @@ * * @since 3.9.0 */ -class PrivacyModelConsents extends JModelList +class ConsentsModel extends ListModel { /** * Constructor. @@ -25,25 +31,25 @@ class PrivacyModelConsents extends JModelList * * @since 3.9.0 */ - public function __construct($config = array()) + public function __construct($config = []) { if (empty($config['filter_fields'])) { - $config['filter_fields'] = array( + $config['filter_fields'] = [ 'id', 'a.id', 'a.user_id', 'created', 'a.created', 'username', 'u.username', - 'state', 'a.state' - ); + 'state', 'a.state', + ]; } parent::__construct($config); } /** - * Method to get a JDatabaseQuery object for retrieving the data set from a database. + * Method to get a DatabaseQuery object for retrieving the data set from a database. * - * @return JDatabaseQuery + * @return DatabaseQuery * * @since 3.9.0 */ @@ -152,7 +158,7 @@ protected function populateState($ordering = 'a.id', $direction = 'desc') ); // Load the parameters. - $this->setState('params', JComponentHelper::getParams('com_privacy')); + $this->setState('params', ComponentHelper::getParams('com_privacy')); // List state information. parent::populateState($ordering, $direction); @@ -182,7 +188,7 @@ public function invalidate($pks) $db->setQuery($query); $db->execute(); } - catch (JDatabaseExceptionExecuting $e) + catch (ExecutionFailureException $e) { $this->setError($e->getMessage()); @@ -212,7 +218,7 @@ public function invalidateAll($subject) $db->setQuery($query); $db->execute(); } - catch (JDatabaseExceptionExecuting $e) + catch (ExecutionFailureException $e) { $this->setError($e->getMessage()); diff --git a/administrator/components/com_privacy/models/dashboard.php b/administrator/components/com_privacy/Model/DashboardModel.php similarity index 73% rename from administrator/components/com_privacy/models/dashboard.php rename to administrator/components/com_privacy/Model/DashboardModel.php index 3ae742f728e65..6794b271ba411 100644 --- a/administrator/components/com_privacy/models/dashboard.php +++ b/administrator/components/com_privacy/Model/DashboardModel.php @@ -7,14 +7,22 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Model; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Menu\MenuItem; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; + /** * Dashboard model class. * * @since 3.9.0 */ -class PrivacyModelDashboard extends JModelLegacy +class DashboardModel extends BaseDatabaseModel { /** * Get the information about the published privacy policy @@ -25,20 +33,20 @@ class PrivacyModelDashboard extends JModelLegacy */ public function getPrivacyPolicyInfo() { - $policy = array( - 'published' => false, - 'articlePublished' => false, - 'editLink' => '', - ); + $policy = [ + 'published' => false, + 'articlePublished' => false, + 'editLink' => '', + ]; /* * Prior to 3.9.0 it was common for a plugin such as the User - Profile plugin to define a privacy policy or * terms of service article, therefore we will also import the user plugin group to process this event. */ - JPluginHelper::importPlugin('privacy'); - JPluginHelper::importPlugin('user'); + PluginHelper::importPlugin('privacy'); + PluginHelper::importPlugin('user'); - JFactory::getApplication()->triggerEvent('onPrivacyCheckPrivacyPolicyPublished', array(&$policy)); + Factory::getApplication()->triggerEvent('onPrivacyCheckPrivacyPolicyPublished', [&$policy]); return $policy; } @@ -55,11 +63,11 @@ public function getRequestCounts() $db = $this->getDbo(); $query = $db->getQuery(true) ->select( - array( + [ 'COUNT(*) AS count', $db->quoteName('status'), $db->quoteName('request_type'), - ) + ] ) ->from($db->quoteName('#__privacy_requests')) ->group($db->quoteName('status')) @@ -79,16 +87,16 @@ public function getRequestCounts() */ public function getRequestFormPublished() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $menu = $app->getMenu('site'); $item = $menu->getItems('link', 'index.php?option=com_privacy&view=request', true); - $status = array( + $status = [ 'exists' => false, 'published' => false, 'link' => '', - ); + ]; $db = $this->getDbo(); $query = $db->getQuery(true) @@ -106,14 +114,14 @@ public function getRequestFormPublished() $linkMode = $app->get('force_ssl', 0) == 2 ? 1 : -1; - if (!($item instanceof JMenuItem)) + if (!($item instanceof MenuItem)) { - $status['link'] = JRoute::link('site', 'index.php?option=com_privacy&view=request', true, $linkMode); + $status['link'] = Route::link('site', 'index.php?option=com_privacy&view=request', true, $linkMode); } else { $status['published'] = true; - $status['link'] = JRoute::link('site', 'index.php?Itemid=' . $item->id, true, $linkMode); + $status['link'] = Route::link('site', 'index.php?Itemid=' . $item->id, true, $linkMode); } return $status; diff --git a/administrator/components/com_privacy/models/export.php b/administrator/components/com_privacy/Model/ExportModel.php similarity index 65% rename from administrator/components/com_privacy/models/export.php rename to administrator/components/com_privacy/Model/ExportModel.php index c8bd484857e28..8297e38e48842 100644 --- a/administrator/components/com_privacy/models/export.php +++ b/administrator/components/com_privacy/Model/ExportModel.php @@ -7,23 +7,37 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Model; + defined('_JEXEC') or die; -JLoader::register('PrivacyHelper', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/privacy.php'); +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Language; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\User\User; +use Joomla\Component\Privacy\Administrator\Export\Domain; +use Joomla\Component\Privacy\Administrator\Helper\PrivacyHelper; +use Joomla\Component\Privacy\Administrator\Table\RequestTable; +use PHPMailer\PHPMailer\Exception as phpmailerException; /** * Export model class. * * @since 3.9.0 */ -class PrivacyModelExport extends JModelLegacy +class ExportModel extends BaseDatabaseModel { /** * Create the export document for an information request. * * @param integer $id The request ID to process * - * @return PrivacyExportDomain[]|boolean A SimpleXMLElement object for a successful export or boolean false on an error + * @return Domain[]|boolean A SimpleXMLElement object for a successful export or boolean false on an error * * @since 3.9.0 */ @@ -33,12 +47,12 @@ public function collectDataForExportRequest($id = null) if (!$id) { - $this->setError(JText::_('COM_PRIVACY_ERROR_REQUEST_ID_REQUIRED_FOR_EXPORT')); + $this->setError(Text::_('COM_PRIVACY_ERROR_REQUEST_ID_REQUIRED_FOR_EXPORT')); return false; } - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($id)) @@ -50,14 +64,14 @@ public function collectDataForExportRequest($id = null) if ($table->request_type !== 'export') { - $this->setError(JText::_('COM_PRIVACY_ERROR_REQUEST_TYPE_NOT_EXPORT')); + $this->setError(Text::_('COM_PRIVACY_ERROR_REQUEST_TYPE_NOT_EXPORT')); return false; } if ($table->status != 1) { - $this->setError(JText::_('COM_PRIVACY_ERROR_CANNOT_EXPORT_UNCONFIRMED_REQUEST')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CANNOT_EXPORT_UNCONFIRMED_REQUEST')); return false; } @@ -74,16 +88,16 @@ public function collectDataForExportRequest($id = null) 1 )->loadResult(); - $user = $userId ? JUser::getInstance($userId) : null; + $user = $userId ? User::getInstance($userId) : null; // Log the export $this->logExport($table); - JPluginHelper::importPlugin('privacy'); + PluginHelper::importPlugin('privacy'); - $pluginResults = JFactory::getApplication()->triggerEvent('onPrivacyExportRequest', array($table, $user)); + $pluginResults = Factory::getApplication()->triggerEvent('onPrivacyExportRequest', [$table, $user]); - $domains = array(); + $domains = []; foreach ($pluginResults as $pluginDomains) { @@ -108,7 +122,7 @@ public function emailDataExport($id = null) if (!$id) { - $this->setError(JText::_('COM_PRIVACY_ERROR_REQUEST_ID_REQUIRED_FOR_EXPORT')); + $this->setError(Text::_('COM_PRIVACY_ERROR_REQUEST_ID_REQUIRED_FOR_EXPORT')); return false; } @@ -121,7 +135,7 @@ public function emailDataExport($id = null) return false; } - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($id)) @@ -133,14 +147,14 @@ public function emailDataExport($id = null) if ($table->request_type !== 'export') { - $this->setError(JText::_('COM_PRIVACY_ERROR_REQUEST_TYPE_NOT_EXPORT')); + $this->setError(Text::_('COM_PRIVACY_ERROR_REQUEST_TYPE_NOT_EXPORT')); return false; } if ($table->status != 1) { - $this->setError(JText::_('COM_PRIVACY_ERROR_CANNOT_EXPORT_UNCONFIRMED_REQUEST')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CANNOT_EXPORT_UNCONFIRMED_REQUEST')); return false; } @@ -156,7 +170,7 @@ public function emailDataExport($id = null) * Error messages will still be displayed to the administrator, so those messages should continue to use the Text class. */ - $lang = JFactory::getLanguage(); + $lang = Factory::getLanguage(); $db = $this->getDbo(); @@ -171,7 +185,7 @@ public function emailDataExport($id = null) if ($userId) { - $receiver = JUser::getInstance($userId); + $receiver = User::getInstance($userId); /* * We don't know if the user has admin access, so we will check if they have an admin language in their parameters, @@ -185,7 +199,7 @@ public function emailDataExport($id = null) $langCode = $receiver->getParam('language', $lang->getTag()); } - $lang = JLanguage::getInstance($langCode, $lang->getDebug()); + $lang = Language::getInstance($langCode, $lang->getDebug()); } // Ensure the right language files have been loaded @@ -195,13 +209,13 @@ public function emailDataExport($id = null) // The mailer can be set to either throw Exceptions or return boolean false, account for both try { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); - $substitutions = array( + $substitutions = [ '[SITENAME]' => $app->get('sitename'), - '[URL]' => JUri::root(), + '[URL]' => Uri::root(), '\\n' => "\n", - ); + ]; $emailSubject = $lang->_('COM_PRIVACY_EMAIL_DATA_EXPORT_COMPLETED_SUBJECT'); $emailBody = $lang->_('COM_PRIVACY_EMAIL_DATA_EXPORT_COMPLETED_BODY'); @@ -212,23 +226,16 @@ public function emailDataExport($id = null) $emailBody = str_replace($k, $v, $emailBody); } - $mailer = JFactory::getMailer(); + $mailer = Factory::getMailer(); $mailer->setSubject($emailSubject); $mailer->setBody($emailBody); $mailer->addRecipient($table->email); $mailer->addStringAttachment( PrivacyHelper::renderDataAsXml($exportData), - 'user-data_' . JUri::getInstance()->toString(array('host')) . '.xml' + 'user-data_' . Uri::getInstance()->toString(['host']) . '.xml' ); - $mailResult = $mailer->Send(); - - if ($mailResult instanceof JException) - { - // JError was already called so we just need to return now - return false; - } - elseif ($mailResult === false) + if ($mailer->Send() === false) { $this->setError($mailer->ErrorInfo); @@ -254,12 +261,12 @@ public function emailDataExport($id = null) * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * - * @return JTable A JTable object + * @return Table A Table object * * @since 3.9.0 * @throws \Exception */ - public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = array()) + public function getTable($name = 'Request', $prefix = 'Administrator', $options = []) { return parent::getTable($name, $prefix, $options); } @@ -267,59 +274,51 @@ public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = /** * Log the data export to the action log system. * - * @param PrivacyTableRequest $request The request record being processed + * @param RequestTable $request The request record being processed * * @return void * * @since 3.9.0 */ - public function logExport(PrivacyTableRequest $request) + public function logExport(RequestTable $request) { - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - - $user = JFactory::getUser(); + $user = Factory::getUser(); - $message = array( + $message = [ 'action' => 'export', 'id' => $request->id, 'itemlink' => 'index.php?option=com_privacy&view=request&id=' . $request->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_EXPORT', 'com_privacy.request', $user->id); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_EXPORT', 'com_privacy.request', $user->id); } /** * Log the data export email to the action log system. * - * @param PrivacyTableRequest $request The request record being processed + * @param RequestTable $request The request record being processed * * @return void * * @since 3.9.0 */ - public function logExportEmailed(PrivacyTableRequest $request) + public function logExportEmailed(RequestTable $request) { - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + $user = Factory::getUser(); - $user = JFactory::getUser(); - - $message = array( + $message = [ 'action' => 'export_emailed', 'id' => $request->id, 'itemlink' => 'index.php?option=com_privacy&view=request&id=' . $request->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_EXPORT_EMAILED', 'com_privacy.request', $user->id); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_EXPORT_EMAILED', 'com_privacy.request', $user->id); } /** @@ -332,9 +331,23 @@ public function logExportEmailed(PrivacyTableRequest $request) protected function populateState() { // Get the pk of the record from the request. - $this->setState($this->getName() . '.request_id', JFactory::getApplication()->input->getUint('id')); + $this->setState($this->getName() . '.request_id', Factory::getApplication()->input->getUint('id')); // Load the parameters. - $this->setState('params', JComponentHelper::getParams('com_privacy')); + $this->setState('params', ComponentHelper::getParams('com_privacy')); + } + + /** + * Method to fetch an instance of the action log model. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function getActionlogModel(): \ActionlogsModelActionlog + { + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + + return BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel'); } } diff --git a/administrator/components/com_privacy/models/remove.php b/administrator/components/com_privacy/Model/RemoveModel.php similarity index 54% rename from administrator/components/com_privacy/models/remove.php rename to administrator/components/com_privacy/Model/RemoveModel.php index a5f6505a46326..525ef003f09fd 100644 --- a/administrator/components/com_privacy/models/remove.php +++ b/administrator/components/com_privacy/Model/RemoveModel.php @@ -7,17 +7,26 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Model; + defined('_JEXEC') or die; -JLoader::register('PrivacyHelper', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/privacy.php'); -JLoader::register('PrivacyRemovalStatus', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/removal/status.php'); +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Table\Table; +use Joomla\CMS\User\User; +use Joomla\Component\Privacy\Administrator\Removal\Status; +use Joomla\Component\Privacy\Administrator\Table\RequestTable; /** * Remove model class. * * @since 3.9.0 */ -class PrivacyModelRemove extends JModelLegacy +class RemoveModel extends BaseDatabaseModel { /** * Remove the user data. @@ -34,12 +43,12 @@ public function removeDataForRequest($id = null) if (!$id) { - $this->setError(JText::_('COM_PRIVACY_ERROR_REQUEST_ID_REQUIRED_FOR_REMOVE')); + $this->setError(Text::_('COM_PRIVACY_ERROR_REQUEST_ID_REQUIRED_FOR_REMOVE')); return false; } - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($id)) @@ -51,14 +60,14 @@ public function removeDataForRequest($id = null) if ($table->request_type !== 'remove') { - $this->setError(JText::_('COM_PRIVACY_ERROR_REQUEST_TYPE_NOT_REMOVE')); + $this->setError(Text::_('COM_PRIVACY_ERROR_REQUEST_TYPE_NOT_REMOVE')); return false; } if ($table->status != 1) { - $this->setError(JText::_('COM_PRIVACY_ERROR_CANNOT_REMOVE_UNCONFIRMED_REQUEST')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CANNOT_REMOVE_UNCONFIRMED_REQUEST')); return false; } @@ -75,20 +84,20 @@ public function removeDataForRequest($id = null) 1 )->loadResult(); - $user = $userId ? JUser::getInstance($userId) : null; + $user = $userId ? User::getInstance($userId) : null; $canRemove = true; - JPluginHelper::importPlugin('privacy'); + PluginHelper::importPlugin('privacy'); - /** @var PrivacyRemovalStatus[] $pluginResults */ - $pluginResults = JFactory::getApplication()->triggerEvent('onPrivacyCanRemoveData', array($table, $user)); + /** @var Status[] $pluginResults */ + $pluginResults = Factory::getApplication()->triggerEvent('onPrivacyCanRemoveData', [$table, $user]); foreach ($pluginResults as $status) { if (!$status->canRemove) { - $this->setError($status->reason ?: JText::_('COM_PRIVACY_ERROR_CANNOT_REMOVE_DATA')); + $this->setError($status->reason ?: Text::_('COM_PRIVACY_ERROR_CANNOT_REMOVE_DATA')); $canRemove = false; } @@ -104,7 +113,7 @@ public function removeDataForRequest($id = null) // Log the removal $this->logRemove($table); - JFactory::getApplication()->triggerEvent('onPrivacyRemoveData', array($table, $user)); + Factory::getApplication()->triggerEvent('onPrivacyRemoveData', [$table, $user]); return true; } @@ -116,12 +125,12 @@ public function removeDataForRequest($id = null) * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * - * @return JTable A JTable object + * @return Table A Table object * * @since 3.9.0 * @throws \Exception */ - public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = array()) + public function getTable($name = 'Request', $prefix = 'Administrator', $options = []) { return parent::getTable($name, $prefix, $options); } @@ -129,49 +138,43 @@ public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = /** * Log the data removal to the action log system. * - * @param PrivacyTableRequest $request The request record being processed + * @param RequestTable $request The request record being processed * * @return void * * @since 3.9.0 */ - public function logRemove(PrivacyTableRequest $request) + public function logRemove(RequestTable $request) { - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - - $user = JFactory::getUser(); + $user = Factory::getUser(); - $message = array( + $message = [ 'action' => 'remove', 'id' => $request->id, 'itemlink' => 'index.php?option=com_privacy&view=request&id=' . $request->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_REMOVE', 'com_privacy.request', $user->id); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_REMOVE', 'com_privacy.request', $user->id); } /** * Log the data removal being blocked to the action log system. * - * @param PrivacyTableRequest $request The request record being processed - * @param string[] $reasons The reasons given why the record could not be removed. + * @param RequestTable $request The request record being processed + * @param string[] $reasons The reasons given why the record could not be removed. * * @return void * * @since 3.9.0 */ - public function logRemoveBlocked(PrivacyTableRequest $request, array $reasons) + public function logRemoveBlocked(RequestTable $request, array $reasons) { - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - - $user = JFactory::getUser(); + $user = Factory::getUser(); - $message = array( + $message = [ 'action' => 'remove-blocked', 'id' => $request->id, 'itemlink' => 'index.php?option=com_privacy&view=request&id=' . $request->id, @@ -179,11 +182,9 @@ public function logRemoveBlocked(PrivacyTableRequest $request, array $reasons) 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'reasons' => implode('; ', $reasons), - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_REMOVE_BLOCKED', 'com_privacy.request', $user->id); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_REMOVE_BLOCKED', 'com_privacy.request', $user->id); } /** @@ -196,9 +197,23 @@ public function logRemoveBlocked(PrivacyTableRequest $request, array $reasons) protected function populateState() { // Get the pk of the record from the request. - $this->setState($this->getName() . '.request_id', JFactory::getApplication()->input->getUint('id')); + $this->setState($this->getName() . '.request_id', Factory::getApplication()->input->getUint('id')); // Load the parameters. - $this->setState('params', JComponentHelper::getParams('com_privacy')); + $this->setState('params', ComponentHelper::getParams('com_privacy')); + } + + /** + * Method to fetch an instance of the action log model. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function getActionlogModel(): \ActionlogsModelActionlog + { + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + + return BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel'); } } diff --git a/administrator/components/com_privacy/models/request.php b/administrator/components/com_privacy/Model/RequestModel.php similarity index 70% rename from administrator/components/com_privacy/models/request.php rename to administrator/components/com_privacy/Model/RequestModel.php index ceb00f11399e4..002da1420d727 100644 --- a/administrator/components/com_privacy/models/request.php +++ b/administrator/components/com_privacy/Model/RequestModel.php @@ -7,28 +7,45 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Model; + defined('_JEXEC') or die; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Language; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\User\User; +use Joomla\CMS\User\UserHelper; +use Joomla\Component\Privacy\Administrator\Table\RequestTable; +use Joomla\Database\Exception\ExecutionFailureException; +use PHPMailer\PHPMailer\Exception as phpmailerException; + /** * Request item model class. * * @since 3.9.0 */ -class PrivacyModelRequest extends JModelAdmin +class RequestModel extends AdminModel { /** * Clean the cache * - * @param string $group The cache group - * @param integer $client_id The ID of the client + * @param string $group The cache group * * @return void * * @since 3.9.0 */ - protected function cleanCache($group = 'com_privacy', $client_id = 1) + protected function cleanCache($group = 'com_privacy') { - parent::cleanCache('com_privacy', 1); + parent::cleanCache('com_privacy'); } /** @@ -37,14 +54,14 @@ protected function cleanCache($group = 'com_privacy', $client_id = 1) * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * - * @return JForm|boolean A JForm object on success, false on failure + * @return Form|boolean A Form object on success, false on failure * * @since 3.9.0 */ - public function getForm($data = array(), $loadData = true) + public function getForm($data = [], $loadData = true) { // Get the form. - $form = $this->loadForm('com_privacy.request', 'request', array('control' => 'jform', 'load_data' => $loadData)); + $form = $this->loadForm('com_privacy.request', 'request', ['control' => 'jform', 'load_data' => $loadData]); if (empty($form)) { @@ -61,12 +78,12 @@ public function getForm($data = array(), $loadData = true) * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * - * @return JTable A JTable object + * @return Table A Table object * * @since 3.9.0 * @throws \Exception */ - public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = array()) + public function getTable($name = 'Request', $prefix = 'Administrator', $options = []) { return parent::getTable($name, $prefix, $options); } @@ -81,7 +98,7 @@ public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_privacy.edit.request.data', array()); + $data = Factory::getApplication()->getUserState('com_privacy.edit.request.data', []); if (empty($data)) { @@ -102,7 +119,7 @@ protected function loadFormData() */ public function logRequestCompleted($id) { - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($id)) @@ -112,11 +129,9 @@ public function logRequestCompleted($id) return false; } - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - - $user = JFactory::getUser(); + $user = Factory::getUser(); - $message = array( + $message = [ 'action' => 'request-completed', 'requesttype' => $table->request_type, 'subjectemail' => $table->email, @@ -125,11 +140,9 @@ public function logRequestCompleted($id) 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_ADMIN_COMPLETED_REQUEST', 'com_privacy.request', $user->id); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_ADMIN_COMPLETED_REQUEST', 'com_privacy.request', $user->id); return true; } @@ -145,7 +158,7 @@ public function logRequestCompleted($id) */ public function logRequestCreated($id) { - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($id)) @@ -155,11 +168,9 @@ public function logRequestCreated($id) return false; } - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + $user = Factory::getUser(); - $user = JFactory::getUser(); - - $message = array( + $message = [ 'action' => 'request-created', 'requesttype' => $table->request_type, 'subjectemail' => $table->email, @@ -168,11 +179,9 @@ public function logRequestCreated($id) 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_ADMIN_CREATED_REQUEST', 'com_privacy.request', $user->id); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_ADMIN_CREATED_REQUEST', 'com_privacy.request', $user->id); return true; } @@ -188,7 +197,7 @@ public function logRequestCreated($id) */ public function logRequestInvalidated($id) { - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($id)) @@ -198,11 +207,9 @@ public function logRequestInvalidated($id) return false; } - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - - $user = JFactory::getUser(); + $user = Factory::getUser(); - $message = array( + $message = [ 'action' => 'request-invalidated', 'requesttype' => $table->request_type, 'subjectemail' => $table->email, @@ -211,11 +218,9 @@ public function logRequestInvalidated($id) 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_ADMIN_INVALIDATED_REQUEST', 'com_privacy.request', $user->id); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_ADMIN_INVALIDATED_REQUEST', 'com_privacy.request', $user->id); return true; } @@ -234,7 +239,7 @@ public function logRequestInvalidated($id) */ public function notifyUserAdminCreatedRequest($id) { - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($id)) @@ -252,7 +257,7 @@ public function notifyUserAdminCreatedRequest($id) * Error messages will still be displayed to the administrator, so those messages should continue to use the Text class. */ - $lang = JFactory::getLanguage(); + $lang = Factory::getLanguage(); $db = $this->getDbo(); @@ -267,7 +272,7 @@ public function notifyUserAdminCreatedRequest($id) if ($userId) { - $receiver = JUser::getInstance($userId); + $receiver = User::getInstance($userId); /* * We don't know if the user has admin access, so we will check if they have an admin language in their parameters, @@ -281,7 +286,7 @@ public function notifyUserAdminCreatedRequest($id) $langCode = $receiver->getParam('language', $lang->getTag()); } - $lang = JLanguage::getInstance($langCode, $lang->getDebug()); + $lang = Language::getInstance($langCode, $lang->getDebug()); } // Ensure the right language files have been loaded @@ -289,17 +294,17 @@ public function notifyUserAdminCreatedRequest($id) || $lang->load('com_privacy', JPATH_ADMINISTRATOR . '/components/com_privacy', null, false, true); // Regenerate the confirmation token - $token = JApplicationHelper::getHash(JUserHelper::genRandomPassword()); - $hashedToken = JUserHelper::hashPassword($token); + $token = ApplicationHelper::getHash(UserHelper::genRandomPassword()); + $hashedToken = UserHelper::hashPassword($token); $table->confirm_token = $hashedToken; - $table->confirm_token_created_at = JFactory::getDate()->toSql(); + $table->confirm_token_created_at = Factory::getDate()->toSql(); try { $table->store(); } - catch (JDatabaseException $exception) + catch (ExecutionFailureException $exception) { $this->setError($exception->getMessage()); @@ -309,18 +314,18 @@ public function notifyUserAdminCreatedRequest($id) // The mailer can be set to either throw Exceptions or return boolean false, account for both try { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $linkMode = $app->get('force_ssl', 0) == 2 ? 1 : -1; - $substitutions = array( + $substitutions = [ '[SITENAME]' => $app->get('sitename'), - '[URL]' => JUri::root(), - '[TOKENURL]' => JRoute::link('site', 'index.php?option=com_privacy&view=confirm&confirm_token=' . $token, false, $linkMode), - '[FORMURL]' => JRoute::link('site', 'index.php?option=com_privacy&view=confirm', false, $linkMode), + '[URL]' => Uri::root(), + '[TOKENURL]' => Route::link('site', 'index.php?option=com_privacy&view=confirm&confirm_token=' . $token, false, $linkMode), + '[FORMURL]' => Route::link('site', 'index.php?option=com_privacy&view=confirm', false, $linkMode), '[TOKEN]' => $token, '\\n' => "\n", - ); + ]; switch ($table->request_type) { @@ -337,7 +342,7 @@ public function notifyUserAdminCreatedRequest($id) break; default: - $this->setError(JText::_('COM_PRIVACY_ERROR_UNKNOWN_REQUEST_TYPE')); + $this->setError(Text::_('COM_PRIVACY_ERROR_UNKNOWN_REQUEST_TYPE')); return false; } @@ -348,19 +353,14 @@ public function notifyUserAdminCreatedRequest($id) $emailBody = str_replace($k, $v, $emailBody); } - $mailer = JFactory::getMailer(); + $mailer = Factory::getMailer(); $mailer->setSubject($emailSubject); $mailer->setBody($emailBody); $mailer->addRecipient($table->email); $mailResult = $mailer->Send(); - if ($mailResult instanceof JException) - { - // JError was already called so we just need to return now - return false; - } - elseif ($mailResult === false) + if ($mailer->Send() === false) { $this->setError($mailer->ErrorInfo); @@ -392,9 +392,9 @@ public function save($data) $key = $table->getKeyName(); $pk = !empty($data[$key]) ? $data[$key] : (int) $this->getState($this->getName() . '.id'); - if (!$pk && !JFactory::getConfig()->get('mailonline', 1)) + if (!$pk && !Factory::getConfig()->get('mailonline', 1)) { - $this->setError(JText::_('COM_PRIVACY_ERROR_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED')); return false; } @@ -426,9 +426,9 @@ public function validate($form, $data, $group = null) } // The user cannot create a request for their own account - if (strtolower(JFactory::getUser()->email) === strtolower($validatedData['email'])) + if (strtolower(Factory::getUser()->email) === strtolower($validatedData['email'])) { - $this->setError(JText::_('COM_PRIVACY_ERROR_CANNOT_CREATE_REQUEST_FOR_SELF')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CANNOT_CREATE_REQUEST_FOR_SELF')); return false; } @@ -447,11 +447,25 @@ public function validate($form, $data, $group = null) if ($activeRequestCount > 0) { - $this->setError(JText::_('COM_PRIVACY_ERROR_ACTIVE_REQUEST_FOR_EMAIL')); + $this->setError(Text::_('COM_PRIVACY_ERROR_ACTIVE_REQUEST_FOR_EMAIL')); return false; } return $validatedData; } + + /** + * Method to fetch an instance of the action log model. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function getActionlogModel(): \ActionlogsModelActionlog + { + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + + return BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel'); + } } diff --git a/administrator/components/com_privacy/models/requests.php b/administrator/components/com_privacy/Model/RequestsModel.php similarity index 89% rename from administrator/components/com_privacy/models/requests.php rename to administrator/components/com_privacy/Model/RequestsModel.php index 2f8b6caad0610..adef95a3b289d 100644 --- a/administrator/components/com_privacy/models/requests.php +++ b/administrator/components/com_privacy/Model/RequestsModel.php @@ -7,16 +7,21 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Model; + defined('_JEXEC') or die; use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Database\DatabaseQuery; /** * Requests management model class. * * @since 3.9.0 */ -class PrivacyModelRequests extends JModelList +class RequestsModel extends ListModel { /** * Constructor. @@ -25,26 +30,26 @@ class PrivacyModelRequests extends JModelList * * @since 3.9.0 */ - public function __construct($config = array()) + public function __construct($config = []) { if (empty($config['filter_fields'])) { - $config['filter_fields'] = array( + $config['filter_fields'] = [ 'id', 'a.id', 'email', 'a.email', 'requested_at', 'a.requested_at', 'request_type', 'a.request_type', 'status', 'a.status', - ); + ]; } parent::__construct($config); } /** - * Method to get a JDatabaseQuery object for retrieving the data set from a database. + * Method to get a DatabaseQuery object for retrieving the data set from a database. * - * @return JDatabaseQuery + * @return DatabaseQuery * * @since 3.9.0 */ @@ -156,7 +161,7 @@ protected function populateState($ordering = 'a.id', $direction = 'desc') ); // Load the parameters. - $this->setState('params', JComponentHelper::getParams('com_privacy')); + $this->setState('params', ComponentHelper::getParams('com_privacy')); // List state information. parent::populateState($ordering, $direction); @@ -174,7 +179,7 @@ public function getNumberUrgentRequests() // Load the parameters. $params = ComponentHelper::getComponent('com_privacy')->getParams(); $notify = (int) $params->get('notify', 14); - $now = JFactory::getDate()->toSql(); + $now = Factory::getDate()->toSql(); $period = '-' . $notify; $db = $this->getDbo(); diff --git a/administrator/components/com_privacy/helpers/plugin.php b/administrator/components/com_privacy/Plugin/PrivacyPlugin.php similarity index 78% rename from administrator/components/com_privacy/helpers/plugin.php rename to administrator/components/com_privacy/Plugin/PrivacyPlugin.php index d10f34d216f2b..6111269a3a973 100644 --- a/administrator/components/com_privacy/helpers/plugin.php +++ b/administrator/components/com_privacy/Plugin/PrivacyPlugin.php @@ -7,19 +7,23 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Plugin; + defined('_JEXEC') or die; -JLoader::register('PrivacyExportDomain', __DIR__ . '/export/domain.php'); -JLoader::register('PrivacyExportField', __DIR__ . '/export/field.php'); -JLoader::register('PrivacyExportItem', __DIR__ . '/export/item.php'); -JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); +use Joomla\CMS\Plugin\CMSPlugin; +use Joomla\CMS\Table\Table; +use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; +use Joomla\Component\Privacy\Administrator\Export\Domain; +use Joomla\Component\Privacy\Administrator\Export\Field; +use Joomla\Component\Privacy\Administrator\Export\Item; /** * Base class for privacy plugins * * @since 3.9.0 */ -abstract class PrivacyPlugin extends JPlugin +abstract class PrivacyPlugin extends CMSPlugin { /** * Database object @@ -43,13 +47,13 @@ abstract class PrivacyPlugin extends JPlugin * @param string $name The domain's name * @param string $description The domain's description * - * @return PrivacyExportDomain + * @return Domain * * @since 3.9.0 */ protected function createDomain($name, $description = '') { - $domain = new PrivacyExportDomain; + $domain = new Domain; $domain->name = $name; $domain->description = $description; @@ -62,13 +66,13 @@ protected function createDomain($name, $description = '') * @param array $data The array data to convert * @param integer|null $itemId The ID of this item * - * @return PrivacyExportItem + * @return Item * * @since 3.9.0 */ protected function createItemFromArray(array $data, $itemId = null) { - $item = new PrivacyExportItem; + $item = new Item; $item->id = $itemId; foreach ($data as $key => $value) @@ -83,7 +87,7 @@ protected function createItemFromArray(array $data, $itemId = null) $value = print_r($value, true); } - $field = new PrivacyExportField; + $field = new Field; $field->name = $key; $field->value = $value; @@ -94,17 +98,17 @@ protected function createItemFromArray(array $data, $itemId = null) } /** - * Create an item object for a JTable object + * Create an item object for a Table object * - * @param JTable $table The JTable object to convert + * @param Table $table The Table object to convert * - * @return PrivacyExportItem + * @return Item * * @since 3.9.0 */ protected function createItemForTable($table) { - $data = array(); + $data = []; foreach (array_keys($table->getFields()) as $fieldName) { @@ -120,7 +124,7 @@ protected function createItemForTable($table) * @param string $context The context * @param array $items The items * - * @return PrivacyExportDomain + * @return Domain * * @since 3.9.0 */ @@ -128,14 +132,14 @@ protected function createCustomFieldsDomain($context, $items = array()) { if (!is_array($items)) { - $items = array($items); + $items = [$items]; } $parts = FieldsHelper::extract($context); if (!$parts) { - return array(); + return []; } $type = str_replace('com_', '', $parts[0]); @@ -151,12 +155,12 @@ protected function createCustomFieldsDomain($context, $items = array()) { $fieldValue = is_array($field->value) ? implode(', ', $field->value) : $field->value; - $data = array( + $data = [ $type . '_id' => $item->id, 'field_name' => $field->name, 'field_title' => $field->title, 'field_value' => $fieldValue, - ); + ]; $domain->addItem($this->createItemFromArray($data)); } diff --git a/administrator/components/com_privacy/helpers/removal/status.php b/administrator/components/com_privacy/Removal/Status.php similarity index 91% rename from administrator/components/com_privacy/helpers/removal/status.php rename to administrator/components/com_privacy/Removal/Status.php index fef3dbcd2b7d1..debb360b8189a 100644 --- a/administrator/components/com_privacy/helpers/removal/status.php +++ b/administrator/components/com_privacy/Removal/Status.php @@ -7,6 +7,8 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Removal; + defined('_JEXEC') or die; /** @@ -16,7 +18,7 @@ * * @since 3.9.0 */ -class PrivacyRemovalStatus +class Status { /** * Flag indicating the status reported by the plugin on whether the information can be removed diff --git a/administrator/components/com_privacy/helpers/html/helper.php b/administrator/components/com_privacy/Service/HTML/Privacy.php similarity index 50% rename from administrator/components/com_privacy/helpers/html/helper.php rename to administrator/components/com_privacy/Service/HTML/Privacy.php index 2cac7f9e35c0c..d6aba1a0a6edc 100644 --- a/administrator/components/com_privacy/helpers/html/helper.php +++ b/administrator/components/com_privacy/Service/HTML/Privacy.php @@ -7,14 +7,18 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Service\HTML; + defined('_JEXEC') or die; +use Joomla\CMS\Language\Text; + /** * Privacy component HTML helper. * * @since 3.9.0 */ -class PrivacyHtmlHelper +class Privacy { /** * Render a status label @@ -25,22 +29,22 @@ class PrivacyHtmlHelper * * @since 3.9.0 */ - public static function statusLabel($status) + public function statusLabel($status) { switch ($status) { case 2: - return '' . JText::_('COM_PRIVACY_STATUS_COMPLETED') . ''; + return '' . Text::_('COM_PRIVACY_STATUS_COMPLETED') . ''; case 1: - return '' . JText::_('COM_PRIVACY_STATUS_CONFIRMED') . ''; + return '' . Text::_('COM_PRIVACY_STATUS_CONFIRMED') . ''; case -1: - return '' . JText::_('COM_PRIVACY_STATUS_INVALID') . ''; + return '' . Text::_('COM_PRIVACY_STATUS_INVALID') . ''; default: case 0: - return '' . JText::_('COM_PRIVACY_STATUS_PENDING') . ''; + return '' . Text::_('COM_PRIVACY_STATUS_PENDING') . ''; } } } diff --git a/administrator/components/com_privacy/tables/consent.php b/administrator/components/com_privacy/Table/ConsentTable.php similarity index 80% rename from administrator/components/com_privacy/tables/consent.php rename to administrator/components/com_privacy/Table/ConsentTable.php index aec23c0937cc7..d34edcef73ab0 100644 --- a/administrator/components/com_privacy/tables/consent.php +++ b/administrator/components/com_privacy/Table/ConsentTable.php @@ -7,8 +7,14 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Table; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\Database\DatabaseDriver; + /** * Table interface class for the #__privacy_consents table * @@ -19,16 +25,16 @@ * * @since 3.9.0 */ -class PrivacyTableConsent extends JTable +class ConsentTable extends Table { /** * The class constructor. * - * @param JDatabaseDriver $db JDatabaseDriver connector object. + * @param DatabaseDriver $db DatabaseInterface connector object. * * @since 3.9.0 */ - public function __construct(JDatabaseDriver $db) + public function __construct(DatabaseDriver $db) { parent::__construct('#__privacy_consents', 'id', $db); } @@ -44,7 +50,7 @@ public function __construct(JDatabaseDriver $db) */ public function store($updateNulls = false) { - $date = JFactory::getDate(); + $date = Factory::getDate(); // Set default values for new records if (!$this->id) diff --git a/administrator/components/com_privacy/tables/request.php b/administrator/components/com_privacy/Table/RequestTable.php similarity index 83% rename from administrator/components/com_privacy/tables/request.php rename to administrator/components/com_privacy/Table/RequestTable.php index 3428a90e6596c..719a9ec5e96dd 100644 --- a/administrator/components/com_privacy/tables/request.php +++ b/administrator/components/com_privacy/Table/RequestTable.php @@ -7,8 +7,14 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\Table; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\Database\DatabaseDriver; + /** * Table interface class for the #__privacy_requests table * @@ -22,16 +28,16 @@ * * @since 3.9.0 */ -class PrivacyTableRequest extends JTable +class RequestTable extends Table { /** * The class constructor. * - * @param JDatabaseDriver $db JDatabaseDriver connector object. + * @param DatabaseDriver $db DatabaseDriver connector object. * * @since 3.9.0 */ - public function __construct(JDatabaseDriver $db) + public function __construct(DatabaseDriver $db) { parent::__construct('#__privacy_requests', 'id', $db); } @@ -47,7 +53,7 @@ public function __construct(JDatabaseDriver $db) */ public function store($updateNulls = false) { - $date = JFactory::getDate(); + $date = Factory::getDate(); // Set default values for new records if (!$this->id) diff --git a/administrator/components/com_privacy/views/capabilities/view.html.php b/administrator/components/com_privacy/View/Capabilities/HtmlView.php similarity index 68% rename from administrator/components/com_privacy/views/capabilities/view.html.php rename to administrator/components/com_privacy/View/Capabilities/HtmlView.php index 427508dcab598..712db26d29899 100644 --- a/administrator/components/com_privacy/views/capabilities/view.html.php +++ b/administrator/components/com_privacy/View/Capabilities/HtmlView.php @@ -7,14 +7,21 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Capabilities; + defined('_JEXEC') or die; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Toolbar\ToolbarHelper; + /** * Capabilities view class * * @since 3.9.0 */ -class PrivacyViewCapabilities extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The reported extension capabilities @@ -35,7 +42,7 @@ class PrivacyViewCapabilities extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -47,7 +54,7 @@ class PrivacyViewCapabilities extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -60,12 +67,12 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + $this->sidebar = \JHtmlSidebar::render(); return parent::display($tpl); } @@ -79,10 +86,10 @@ public function display($tpl = null) */ protected function addToolbar() { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_CAPABILITIES'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_CAPABILITIES'), 'lock'); - JToolbarHelper::preferences('com_privacy'); + ToolbarHelper::preferences('com_privacy'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CAPABILITIES'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CAPABILITIES'); } } diff --git a/administrator/components/com_privacy/views/consents/view.html.php b/administrator/components/com_privacy/View/Consents/HtmlView.php similarity index 76% rename from administrator/components/com_privacy/views/consents/view.html.php rename to administrator/components/com_privacy/View/Consents/HtmlView.php index b931c811dc9af..6c66fbf39ee8a 100644 --- a/administrator/components/com_privacy/views/consents/view.html.php +++ b/administrator/components/com_privacy/View/Consents/HtmlView.php @@ -7,14 +7,24 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Consents; + defined('_JEXEC') or die; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Pagination\Pagination; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Toolbar\ToolbarHelper; + /** * Consents view class * * @since 3.9.0 */ -class PrivacyViewConsents extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The active search tools filters @@ -28,7 +38,7 @@ class PrivacyViewConsents extends JViewLegacy /** * Form instance containing the search tools filter form * - * @var JForm + * @var Form * @since 3.9.0 * @note Must be public to be accessed from the search tools layout */ @@ -45,7 +55,7 @@ class PrivacyViewConsents extends JViewLegacy /** * The pagination object * - * @var JPagination + * @var Pagination * @since 3.9.0 */ protected $pagination; @@ -61,7 +71,7 @@ class PrivacyViewConsents extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -73,7 +83,7 @@ class PrivacyViewConsents extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -89,12 +99,12 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + $this->sidebar = \JHtmlSidebar::render(); return parent::display($tpl); } @@ -108,9 +118,9 @@ public function display($tpl = null) */ protected function addToolbar() { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_CONSENTS'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_CONSENTS'), 'lock'); - $bar = JToolbar::getInstance('toolbar'); + $bar = Toolbar::getInstance('toolbar'); // Add a button to invalidate a consent $bar->appendButton( @@ -135,8 +145,8 @@ protected function addToolbar() ); } - JToolbarHelper::preferences('com_privacy'); + ToolbarHelper::preferences('com_privacy'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CONSENTS'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CONSENTS'); } } diff --git a/administrator/components/com_privacy/views/dashboard/view.html.php b/administrator/components/com_privacy/View/Dashboard/HtmlView.php similarity index 72% rename from administrator/components/com_privacy/views/dashboard/view.html.php rename to administrator/components/com_privacy/View/Dashboard/HtmlView.php index f9fcd32b54467..9bcaa164a9481 100644 --- a/administrator/components/com_privacy/views/dashboard/view.html.php +++ b/administrator/components/com_privacy/View/Dashboard/HtmlView.php @@ -7,14 +7,22 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Dashboard; + defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; + /** * Dashboard view class * * @since 3.9.0 */ -class PrivacyViewDashboard extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * Number of urgent requests based on the component configuration @@ -71,7 +79,7 @@ class PrivacyViewDashboard extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -81,7 +89,7 @@ public function display($tpl = null) $this->privacyPolicyInfo = $this->get('PrivacyPolicyInfo'); $this->requestCounts = $this->get('RequestCounts'); $this->requestFormPublished = $this->get('RequestFormPublished'); - $this->sendMailEnabled = (bool) JFactory::getConfig()->get('mailonline', 1); + $this->sendMailEnabled = (bool) Factory::getConfig()->get('mailonline', 1); /** @var PrivacyModelRequests $requestsModel */ $requestsModel = $this->getModel('requests'); @@ -91,14 +99,14 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } - $this->urgentRequestDays = (int) JComponentHelper::getParams('com_privacy')->get('notify', 14); + $this->urgentRequestDays = (int) ComponentHelper::getParams('com_privacy')->get('notify', 14); $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + $this->sidebar = \JHtmlSidebar::render(); return parent::display($tpl); } @@ -112,10 +120,10 @@ public function display($tpl = null) */ protected function addToolbar() { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_DASHBOARD'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_DASHBOARD'), 'lock'); - JToolbarHelper::preferences('com_privacy'); + ToolbarHelper::preferences('com_privacy'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_DASHBOARD'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_DASHBOARD'); } } diff --git a/administrator/components/com_privacy/views/export/view.xml.php b/administrator/components/com_privacy/View/Export/XmlView.php similarity index 76% rename from administrator/components/com_privacy/views/export/view.xml.php rename to administrator/components/com_privacy/View/Export/XmlView.php index dcb1fe5227629..a66fc0494d1f3 100644 --- a/administrator/components/com_privacy/views/export/view.xml.php +++ b/administrator/components/com_privacy/View/Export/XmlView.php @@ -7,9 +7,13 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Export; + defined('_JEXEC') or die; -JLoader::register('PrivacyHelper', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/privacy.php'); +use Joomla\CMS\MVC\View\AbstractView; +use Joomla\Component\Privacy\Administrator\Helper\PrivacyHelper; +use Joomla\Component\Privacy\Administrator\Model\ExportModel; /** * Export view class @@ -18,7 +22,7 @@ * * @property-read \Joomla\CMS\Document\XmlDocument $document */ -class PrivacyViewExport extends JViewLegacy +class XmlView extends AbstractView { /** * Execute and display a template script. @@ -27,13 +31,12 @@ class PrivacyViewExport extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() * @since 3.9.0 * @throws Exception */ public function display($tpl = null) { - /** @var PrivacyModelExport $model */ + /** @var ExportModel $model */ $model = $this->getModel(); $exportData = $model->collectDataForExportRequest(); @@ -41,7 +44,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } $requestId = $model->getState($model->getName() . '.request_id'); diff --git a/administrator/components/com_privacy/views/request/view.html.php b/administrator/components/com_privacy/View/Request/HtmlView.php similarity index 67% rename from administrator/components/com_privacy/views/request/view.html.php rename to administrator/components/com_privacy/View/Request/HtmlView.php index 5697a820652e7..304c9832a6f92 100644 --- a/administrator/components/com_privacy/views/request/view.html.php +++ b/administrator/components/com_privacy/View/Request/HtmlView.php @@ -7,14 +7,25 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Request; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Toolbar\ToolbarHelper; + /** * Request view class * * @since 3.9.0 */ -class PrivacyViewRequest extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The action logs for the item @@ -27,7 +38,7 @@ class PrivacyViewRequest extends JViewLegacy /** * The form object * - * @var JForm + * @var Form * @since 3.9.0 */ protected $form; @@ -35,7 +46,7 @@ class PrivacyViewRequest extends JViewLegacy /** * The item record * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $item; @@ -43,7 +54,7 @@ class PrivacyViewRequest extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -55,7 +66,7 @@ class PrivacyViewRequest extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -68,13 +79,13 @@ public function display($tpl = null) // Variables only required for the default layout if ($this->getLayout() === 'default') { - /** @var ActionlogsModelActionlogs $logsModel */ + /** @var \ActionlogsModelActionlogs $logsModel */ $logsModel = $this->getModel('actionlogs'); $this->actionlogs = $logsModel->getLogsForItem('com_privacy.request', $this->item->id); // Load the com_actionlogs language strings for use in the layout - $lang = JFactory::getLanguage(); + $lang = Factory::getLanguage(); $lang->load('com_actionlogs', JPATH_ADMINISTRATOR, null, false, true) || $lang->load('com_actionlogs', JPATH_ADMINISTRATOR . '/components/com_actionlogs', null, false, true); } @@ -88,7 +99,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } $this->addToolbar(); @@ -105,22 +116,22 @@ public function display($tpl = null) */ protected function addToolbar() { - JFactory::getApplication('administrator')->set('hidemainmenu', true); + Factory::getApplication('administrator')->set('hidemainmenu', true); // Set the title and toolbar based on the layout if ($this->getLayout() === 'edit') { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_REQUEST_ADD_REQUEST'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUEST_ADD_REQUEST'), 'lock'); - JToolbarHelper::apply('request.save'); - JToolbarHelper::cancel('request.cancel'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST_EDIT'); + ToolbarHelper::apply('request.save'); + ToolbarHelper::cancel('request.cancel'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST_EDIT'); } else { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_REQUEST_SHOW_REQUEST'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUEST_SHOW_REQUEST'), 'lock'); - $bar = JToolbar::getInstance('toolbar'); + $bar = Toolbar::getInstance('toolbar'); // Add transition and action buttons based on item status switch ($this->item->status) @@ -138,16 +149,16 @@ protected function addToolbar() if ($this->item->request_type === 'export') { - JToolbarHelper::link( - JRoute::_('index.php?option=com_privacy&task=request.export&format=xml&id=' . (int) $this->item->id . $return), + ToolbarHelper::link( + Route::_('index.php?option=com_privacy&task=request.export&format=xml&id=' . (int) $this->item->id . $return), 'COM_PRIVACY_ACTION_EXPORT_DATA', 'download' ); - if (JFactory::getConfig()->get('mailonline', 1)) + if (Factory::getConfig()->get('mailonline', 1)) { - JToolbarHelper::link( - JRoute::_('index.php?option=com_privacy&task=request.emailexport&id=' . (int) $this->item->id . $return), + ToolbarHelper::link( + Route::_('index.php?option=com_privacy&task=request.emailexport&id=' . (int) $this->item->id . $return), 'COM_PRIVACY_ACTION_EMAIL_EXPORT_DATA', 'mail' ); @@ -166,8 +177,8 @@ protected function addToolbar() break; } - JToolbarHelper::cancel('request.cancel', 'JTOOLBAR_CLOSE'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST'); + ToolbarHelper::cancel('request.cancel', 'JTOOLBAR_CLOSE'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST'); } } } diff --git a/administrator/components/com_privacy/views/requests/view.html.php b/administrator/components/com_privacy/View/Requests/HtmlView.php similarity index 68% rename from administrator/components/com_privacy/views/requests/view.html.php rename to administrator/components/com_privacy/View/Requests/HtmlView.php index ec94a3f771d07..bfc2ce57e7a61 100644 --- a/administrator/components/com_privacy/views/requests/view.html.php +++ b/administrator/components/com_privacy/View/Requests/HtmlView.php @@ -7,14 +7,25 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Requests; + defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Pagination\Pagination; +use Joomla\CMS\Toolbar\ToolbarHelper; + /** * Requests view class * * @since 3.9.0 */ -class PrivacyViewRequests extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The active search tools filters @@ -28,7 +39,7 @@ class PrivacyViewRequests extends JViewLegacy /** * Form instance containing the search tools filter form * - * @var JForm + * @var Form * @since 3.9.0 * @note Must be public to be accessed from the search tools layout */ @@ -45,7 +56,7 @@ class PrivacyViewRequests extends JViewLegacy /** * The pagination object * - * @var JPagination + * @var Pagination * @since 3.9.0 */ protected $pagination; @@ -69,7 +80,7 @@ class PrivacyViewRequests extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -89,7 +100,7 @@ class PrivacyViewRequests extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -101,18 +112,18 @@ public function display($tpl = null) $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); - $this->urgentRequestAge = (int) JComponentHelper::getParams('com_privacy')->get('notify', 14); - $this->sendMailEnabled = (bool) JFactory::getConfig()->get('mailonline', 1); + $this->urgentRequestAge = (int) ComponentHelper::getParams('com_privacy')->get('notify', 14); + $this->sendMailEnabled = (bool) Factory::getConfig()->get('mailonline', 1); // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + $this->sidebar = \JHtmlSidebar::render(); return parent::display($tpl); } @@ -126,16 +137,15 @@ public function display($tpl = null) */ protected function addToolbar() { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_REQUESTS'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUESTS'), 'lock'); // Requests can only be created if mail sending is enabled - if (JFactory::getConfig()->get('mailonline', 1)) + if (Factory::getConfig()->get('mailonline', 1)) { - JToolbarHelper::addNew('request.add'); + ToolbarHelper::addNew('request.add'); } - JToolbarHelper::preferences('com_privacy'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUESTS'); - + ToolbarHelper::preferences('com_privacy'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUESTS'); } } diff --git a/administrator/components/com_privacy/controllers/request.xml.php b/administrator/components/com_privacy/controllers/request.xml.php deleted file mode 100644 index ca6da52cb4994..0000000000000 --- a/administrator/components/com_privacy/controllers/request.xml.php +++ /dev/null @@ -1,32 +0,0 @@ -input->set('view', 'export'); - - return $this->display(); - } -} diff --git a/administrator/components/com_privacy/models/forms/filter_consents.xml b/administrator/components/com_privacy/forms/filter_consents.xml similarity index 100% rename from administrator/components/com_privacy/models/forms/filter_consents.xml rename to administrator/components/com_privacy/forms/filter_consents.xml diff --git a/administrator/components/com_privacy/models/forms/filter_requests.xml b/administrator/components/com_privacy/forms/filter_requests.xml similarity index 91% rename from administrator/components/com_privacy/models/forms/filter_requests.xml rename to administrator/components/com_privacy/forms/filter_requests.xml index 697ba2188baac..90bc7a53056a2 100644 --- a/administrator/components/com_privacy/models/forms/filter_requests.xml +++ b/administrator/components/com_privacy/forms/filter_requests.xml @@ -1,7 +1,5 @@ -
-
- + authorise('core.admin')) -{ - throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); -} - -$controller = JControllerLegacy::getInstance('Privacy'); -$controller->execute(JFactory::getApplication()->input->get('task')); -$controller->redirect(); diff --git a/administrator/components/com_privacy/privacy.xml b/administrator/components/com_privacy/privacy.xml index 20fd0026bf346..abf190f991032 100644 --- a/administrator/components/com_privacy/privacy.xml +++ b/administrator/components/com_privacy/privacy.xml @@ -9,6 +9,7 @@ www.joomla.org 3.9.0 COM_PRIVACY_XML_DESCRIPTION + Joomla\Component\Privacy controller.php privacy.php diff --git a/administrator/components/com_privacy/services/provider.php b/administrator/components/com_privacy/services/provider.php new file mode 100644 index 0000000000000..97a092da762ce --- /dev/null +++ b/administrator/components/com_privacy/services/provider.php @@ -0,0 +1,56 @@ +registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Privacy')); + $container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Privacy')); + + $container->set( + ComponentInterface::class, + function (Container $container) + { + $component = new PrivacyComponent($container->get(ComponentDispatcherFactoryInterface::class)); + + $component->setMVCFactory($container->get(MVCFactoryInterface::class)); + $component->setRegistry($container->get(Registry::class)); + + return $component; + } + ); + } +}; diff --git a/administrator/components/com_privacy/views/capabilities/tmpl/default.php b/administrator/components/com_privacy/tmpl/capabilities/default.php similarity index 100% rename from administrator/components/com_privacy/views/capabilities/tmpl/default.php rename to administrator/components/com_privacy/tmpl/capabilities/default.php diff --git a/administrator/components/com_privacy/views/consents/tmpl/default.php b/administrator/components/com_privacy/tmpl/consents/default.php similarity index 100% rename from administrator/components/com_privacy/views/consents/tmpl/default.php rename to administrator/components/com_privacy/tmpl/consents/default.php diff --git a/administrator/components/com_privacy/views/consents/tmpl/default.xml b/administrator/components/com_privacy/tmpl/consents/default.xml similarity index 100% rename from administrator/components/com_privacy/views/consents/tmpl/default.xml rename to administrator/components/com_privacy/tmpl/consents/default.xml diff --git a/administrator/components/com_privacy/views/dashboard/tmpl/default.php b/administrator/components/com_privacy/tmpl/dashboard/default.php similarity index 98% rename from administrator/components/com_privacy/views/dashboard/tmpl/default.php rename to administrator/components/com_privacy/tmpl/dashboard/default.php index 16c449c052866..8767b9c0b9ff1 100644 --- a/administrator/components/com_privacy/views/dashboard/tmpl/default.php +++ b/administrator/components/com_privacy/tmpl/dashboard/default.php @@ -46,7 +46,7 @@ request_type); ?> -
status); ?>
+
status); ?>
count; ?>
status, array(0, 1))) : ?> diff --git a/administrator/components/com_privacy/views/dashboard/tmpl/default.xml b/administrator/components/com_privacy/tmpl/dashboard/default.xml similarity index 100% rename from administrator/components/com_privacy/views/dashboard/tmpl/default.xml rename to administrator/components/com_privacy/tmpl/dashboard/default.xml diff --git a/administrator/components/com_privacy/views/request/tmpl/default.php b/administrator/components/com_privacy/tmpl/request/default.php similarity index 96% rename from administrator/components/com_privacy/views/request/tmpl/default.php rename to administrator/components/com_privacy/tmpl/request/default.php index ef1612a3f1e0d..b0d8500659ae6 100644 --- a/administrator/components/com_privacy/views/request/tmpl/default.php +++ b/administrator/components/com_privacy/tmpl/request/default.php @@ -37,7 +37,7 @@
item->email; ?>
:
-
item->status); ?>
+
item->status); ?>
:
item->request_type); ?>
diff --git a/administrator/components/com_privacy/views/request/tmpl/edit.php b/administrator/components/com_privacy/tmpl/request/edit.php similarity index 100% rename from administrator/components/com_privacy/views/request/tmpl/edit.php rename to administrator/components/com_privacy/tmpl/request/edit.php diff --git a/administrator/components/com_privacy/views/requests/tmpl/default.php b/administrator/components/com_privacy/tmpl/requests/default.php similarity index 98% rename from administrator/components/com_privacy/views/requests/tmpl/default.php rename to administrator/components/com_privacy/tmpl/requests/default.php index 8c053f9038227..ae4f5a523fff5 100644 --- a/administrator/components/com_privacy/views/requests/tmpl/default.php +++ b/administrator/components/com_privacy/tmpl/requests/default.php @@ -93,7 +93,7 @@ - status); ?> + status); ?> status == 1 && $urgentRequestDate >= $itemRequestedAt) : ?> diff --git a/administrator/components/com_privacy/views/requests/tmpl/default.xml b/administrator/components/com_privacy/tmpl/requests/default.xml similarity index 100% rename from administrator/components/com_privacy/views/requests/tmpl/default.xml rename to administrator/components/com_privacy/tmpl/requests/default.xml diff --git a/administrator/modules/mod_privacy_dashboard/helper.php b/administrator/modules/mod_privacy_dashboard/helper.php index 1ec75307d7694..454d0cf9d0ec0 100644 --- a/administrator/modules/mod_privacy_dashboard/helper.php +++ b/administrator/modules/mod_privacy_dashboard/helper.php @@ -9,7 +9,9 @@ defined('_JEXEC') or die; -use Joomla\CMS\MVC\Model\BaseModel; +use Joomla\CMS\Factory; +use Joomla\Component\Privacy\Administrator\Model\DashboardModel; +use Joomla\Database\Exception\ExecutionFailureException; /** * Helper class for admin privacy dashboard module @@ -27,18 +29,19 @@ class ModPrivacyDashboardHelper */ public static function getData() { - BaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_privacy/models', 'PrivacyModel'); - - /** @var PrivacyModelDashboard $model */ - $model = BaseModel::getInstance('Dashboard', 'PrivacyModel'); + /** @var DashboardModel $model */ + $model = Factory::getApplication() + ->bootComponent('com_privacy') + ->getMVCFactory() + ->createModel('Dashboard', 'Administrator', ['ignore_request' => true]); try { return $model->getRequestCounts(); } - catch (JDatabaseException $e) + catch (ExecutionFailureException $e) { - return array(); + return []; } } } diff --git a/administrator/modules/mod_privacy_dashboard/mod_privacy_dashboard.php b/administrator/modules/mod_privacy_dashboard/mod_privacy_dashboard.php index 4160610365679..e3cde5595cab3 100644 --- a/administrator/modules/mod_privacy_dashboard/mod_privacy_dashboard.php +++ b/administrator/modules/mod_privacy_dashboard/mod_privacy_dashboard.php @@ -15,6 +15,9 @@ return; } +// Boot component to ensure HTML helpers are loaded +JFactory::getApplication()->bootComponent('com_privacy'); + // Load the privacy component language file. $lang = JFactory::getLanguage(); $lang->load('com_privacy', JPATH_ADMINISTRATOR, null, false, true) diff --git a/administrator/modules/mod_privacy_dashboard/tmpl/default.php b/administrator/modules/mod_privacy_dashboard/tmpl/default.php index 6a18baa7c66fa..aa456b104585c 100644 --- a/administrator/modules/mod_privacy_dashboard/tmpl/default.php +++ b/administrator/modules/mod_privacy_dashboard/tmpl/default.php @@ -29,7 +29,7 @@ request_type); ?> -
status); ?>
+
status); ?>
count; ?>
status, array(0, 1))) : ?> diff --git a/components/com_privacy/controller.php b/components/com_privacy/Controller/DisplayController.php similarity index 64% rename from components/com_privacy/controller.php rename to components/com_privacy/Controller/DisplayController.php index 3818796da0b15..f0dc192c2e744 100644 --- a/components/com_privacy/controller.php +++ b/components/com_privacy/Controller/DisplayController.php @@ -7,14 +7,20 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Site\Controller; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Router\Route; + /** * Privacy Controller * * @since 3.9.0 */ -class PrivacyController extends JControllerLegacy +class DisplayController extends BaseController { /** * Method to display a view. @@ -26,22 +32,22 @@ class PrivacyController extends JControllerLegacy * * @since 3.9.0 */ - public function display($cachable = false, $urlparams = array()) + public function display($cachable = false, $urlparams = []) { $view = $this->input->get('view', $this->default_view); // Submitting information requests through the frontend is restricted to authenticated users at this time - if ($view === 'request' && JFactory::getUser()->guest) + if ($view === 'request' && Factory::getUser()->guest) { - $this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false)); + $this->setRedirect(Route::_('index.php?option=com_users&view=login', false)); return $this; } // Set a Referrer-Policy header for views which require it - if (in_array($view, array('confirm', 'remind'))) + if (in_array($view, ['confirm', 'remind'])) { - JFactory::getApplication()->setHeader('Referrer-Policy', 'no-referrer', true); + Factory::getApplication()->setHeader('Referrer-Policy', 'no-referrer', true); } return parent::display($cachable, $urlparams); diff --git a/components/com_privacy/Controller/RequestController.php b/components/com_privacy/Controller/RequestController.php new file mode 100644 index 0000000000000..dfc319012f1e8 --- /dev/null +++ b/components/com_privacy/Controller/RequestController.php @@ -0,0 +1,190 @@ +checkToken('post'); + + /** @var ConfirmModel $model */ + $model = $this->getModel('Confirm', 'Site'); + $data = $this->input->post->get('jform', [], 'array'); + + $return = $model->confirmRequest($data); + + // Check for a hard error. + if ($return instanceof \Exception) + { + // Get the error message to display. + if (Factory::getApplication()->get('error_reporting')) + { + $message = $return->getMessage(); + } + else + { + $message = Text::_('COM_PRIVACY_ERROR_CONFIRMING_REQUEST'); + } + + // Go back to the confirm form. + $this->setRedirect(Route::_('index.php?option=com_privacy&view=confirm', false), $message, 'error'); + + return false; + } + elseif ($return === false) + { + // Confirm failed. + // Go back to the confirm form. + $message = Text::sprintf('COM_PRIVACY_ERROR_CONFIRMING_REQUEST_FAILED', $model->getError()); + $this->setRedirect(Route::_('index.php?option=com_privacy&view=confirm', false), $message, 'notice'); + + return false; + } + else + { + // Confirm succeeded. + $this->setRedirect(Route::_(Uri::root()), Text::_('COM_PRIVACY_CONFIRM_REQUEST_SUCCEEDED'), 'info'); + + return true; + } + } + + /** + * Method to submit an information request. + * + * @return boolean + * + * @since 3.9.0 + */ + public function submit() + { + // Check the request token. + $this->checkToken('post'); + + /** @var RequestModel $model */ + $model = $this->getModel('Request', 'Site'); + $data = $this->input->post->get('jform', [], 'array'); + + $return = $model->createRequest($data); + + // Check for a hard error. + if ($return instanceof \Exception) + { + // Get the error message to display. + if (Factory::getApplication()->get('error_reporting')) + { + $message = $return->getMessage(); + } + else + { + $message = Text::_('COM_PRIVACY_ERROR_CREATING_REQUEST'); + } + + // Go back to the confirm form. + $this->setRedirect(Route::_('index.php?option=com_privacy&view=request', false), $message, 'error'); + + return false; + } + elseif ($return === false) + { + // Confirm failed. + // Go back to the confirm form. + $message = Text::sprintf('COM_PRIVACY_ERROR_CREATING_REQUEST_FAILED', $model->getError()); + $this->setRedirect(Route::_('index.php?option=com_privacy&view=request', false), $message, 'notice'); + + return false; + } + else + { + // Confirm succeeded. + $this->setRedirect(Route::_(Uri::root()), Text::_('COM_PRIVACY_CREATE_REQUEST_SUCCEEDED'), 'info'); + + return true; + } + } + + /** + * Method to extend the privacy consent. + * + * @return boolean + * + * @since 3.9.0 + */ + public function remind() + { + // Check the request token. + $this->checkToken('post'); + + /** @var ConfirmModel $model */ + $model = $this->getModel('Remind', 'Site'); + $data = $this->input->post->get('jform', [], 'array'); + + $return = $model->remindRequest($data); + + // Check for a hard error. + if ($return instanceof \Exception) + { + // Get the error message to display. + if (Factory::getApplication()->get('error_reporting')) + { + $message = $return->getMessage(); + } + else + { + $message = Text::_('COM_PRIVACY_ERROR_REMIND_REQUEST'); + } + + // Go back to the confirm form. + $this->setRedirect(Route::_('index.php?option=com_privacy&view=remind', false), $message, 'error'); + + return false; + } + elseif ($return === false) + { + // Confirm failed. + // Go back to the confirm form. + $message = Text::sprintf('COM_PRIVACY_ERROR_CONFIRMING_REMIND_FAILED', $model->getError()); + $this->setRedirect(Route::_('index.php?option=com_privacy&view=remind', false), $message, 'notice'); + + return false; + } + else + { + // Confirm succeeded. + $this->setRedirect(Route::_(Uri::root()), Text::_('COM_PRIVACY_CONFIRM_REMIND_SUCCEEDED'), 'info'); + + return true; + } + } +} diff --git a/components/com_privacy/models/confirm.php b/components/com_privacy/Model/ConfirmModel.php similarity index 55% rename from components/com_privacy/models/confirm.php rename to components/com_privacy/Model/ConfirmModel.php index ec09e6f819c8e..a491e742297f8 100644 --- a/components/com_privacy/models/confirm.php +++ b/components/com_privacy/Model/ConfirmModel.php @@ -7,21 +7,36 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Site\Model; + defined('_JEXEC') or die; +use Joomla\CMS\Date\Date; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Table\Table; +use Joomla\CMS\User\UserHelper; +use Joomla\Component\Messages\Administrator\Model\MessageModel; +use Joomla\Component\Privacy\Administrator\Table\RequestTable; +use Joomla\Database\Exception\ExecutionFailureException; + /** * Request confirmation model class. * * @since 3.9.0 */ -class PrivacyModelConfirm extends JModelAdmin +class ConfirmModel extends AdminModel { /** * Confirms the information request. * * @param array $data The data expected for the form. * - * @return mixed Exception | JException | boolean + * @return mixed Exception | boolean * * @since 3.9.0 */ @@ -29,10 +44,10 @@ public function confirmRequest($data) { // Get the form. $form = $this->getForm(); - $data['email'] = JStringPunycode::emailToPunycode($data['email']); + $data['email'] = PunycodeHelper::emailToPunycode($data['email']); // Check for an error. - if ($form instanceof Exception) + if ($form instanceof \Exception) { return $form; } @@ -42,7 +57,7 @@ public function confirmRequest($data) $return = $form->validate($data); // Check for an error. - if ($return instanceof Exception) + if ($return instanceof \Exception) { return $return; } @@ -60,12 +75,12 @@ public function confirmRequest($data) } // Search for the information request - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); - if (!$table->load(array('email' => $data['email'], 'status' => 0))) + if (!$table->load(['email' => $data['email'], 'status' => 0])) { - $this->setError(JText::_('COM_PRIVACY_ERROR_NO_PENDING_REQUESTS')); + $this->setError(Text::_('COM_PRIVACY_ERROR_NO_PENDING_REQUESTS')); return false; } @@ -73,16 +88,16 @@ public function confirmRequest($data) // A request can only be confirmed if it is in a pending status and has a confirmation token if ($table->status != '0' || !$table->confirm_token) { - $this->setError(JText::_('COM_PRIVACY_ERROR_NO_PENDING_REQUESTS')); + $this->setError(Text::_('COM_PRIVACY_ERROR_NO_PENDING_REQUESTS')); return false; } // A request can only be confirmed if the token is less than 24 hours old - $confirmTokenCreatedAt = new JDate($table->confirm_token_created_at); - $confirmTokenCreatedAt->add(new DateInterval('P1D')); + $confirmTokenCreatedAt = new Date($table->confirm_token_created_at); + $confirmTokenCreatedAt->add(new \DateInterval('P1D')); - $now = new JDate('now'); + $now = new Date('now'); if ($now > $confirmTokenCreatedAt) { @@ -94,31 +109,31 @@ public function confirmRequest($data) { $table->store(); } - catch (JDatabaseException $exception) + catch (ExecutionFailureException $exception) { // The error will be logged in the database API, we just need to catch it here to not let things fatal out } - $this->setError(JText::_('COM_PRIVACY_ERROR_CONFIRM_TOKEN_EXPIRED')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CONFIRM_TOKEN_EXPIRED')); return false; } // Verify the token - if (!JUserHelper::verifyPassword($data['confirm_token'], $table->confirm_token)) + if (!UserHelper::verifyPassword($data['confirm_token'], $table->confirm_token)) { - $this->setError(JText::_('COM_PRIVACY_ERROR_NO_PENDING_REQUESTS')); + $this->setError(Text::_('COM_PRIVACY_ERROR_NO_PENDING_REQUESTS')); return false; } // Everything is good to go, transition the request to confirmed $saved = $this->save( - array( - 'id' => $table->id, - 'status' => 1, + [ + 'id' => $table->id, + 'status' => 1, 'confirm_token' => '', - ) + ] ); if (!$saved) @@ -128,29 +143,22 @@ public function confirmRequest($data) } // Push a notification to the site's super users, deliberately ignoring if this process fails so the below message goes out - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/models', 'MessagesModel'); - JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/tables'); - - /** @var MessagesModelMessage $messageModel */ - $messageModel = JModelLegacy::getInstance('Message', 'MessagesModel'); + /** @var MessageModel $messageModel */ + $messageModel = Factory::getApplication()->bootComponent('com_messages')->getMVCFactory()->createModel('Message', 'Administrator'); $messageModel->notifySuperUsers( - JText::_('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CONFIRMED_REQUEST_SUBJECT'), - JText::sprintf('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CONFIRMED_REQUEST_MESSAGE', $table->email) + Text::_('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CONFIRMED_REQUEST_SUBJECT'), + Text::sprintf('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CONFIRMED_REQUEST_MESSAGE', $table->email) ); - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - - $message = array( + $message = [ 'action' => 'request-confirmed', 'subjectemail' => $table->email, 'id' => $table->id, 'itemlink' => 'index.php?option=com_privacy&view=request&id=' . $table->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_CONFIRMED_REQUEST', 'com_privacy.request'); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_CONFIRMED_REQUEST', 'com_privacy.request'); return true; } @@ -161,21 +169,21 @@ public function confirmRequest($data) * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * - * @return JForm|boolean A JForm object on success, false on failure + * @return Form|boolean A Form object on success, false on failure * * @since 3.9.0 */ - public function getForm($data = array(), $loadData = true) + public function getForm($data = [], $loadData = true) { // Get the form. - $form = $this->loadForm('com_privacy.confirm', 'confirm', array('control' => 'jform')); + $form = $this->loadForm('com_privacy.confirm', 'confirm', ['control' => 'jform']); if (empty($form)) { return false; } - $input = JFactory::getApplication()->input; + $input = Factory::getApplication()->input; if ($input->getMethod() === 'GET') { @@ -192,12 +200,12 @@ public function getForm($data = array(), $loadData = true) * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * - * @return JTable A JTable object + * @return Table A Table object * * @since 3.9.0 * @throws \Exception */ - public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = array()) + public function getTable($name = 'Request', $prefix = 'Administrator', $options = []) { return parent::getTable($name, $prefix, $options); } @@ -214,9 +222,23 @@ public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = protected function populateState() { // Get the application object. - $params = JFactory::getApplication()->getParams('com_privacy'); + $params = Factory::getApplication()->getParams('com_privacy'); // Load the parameters. $this->setState('params', $params); } + + /** + * Method to fetch an instance of the action log model. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function getActionlogModel(): \ActionlogsModelActionlog + { + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + + return BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel'); + } } diff --git a/components/com_privacy/models/remind.php b/components/com_privacy/Model/RemindModel.php similarity index 68% rename from components/com_privacy/models/remind.php rename to components/com_privacy/Model/RemindModel.php index c612b7479ac5f..12c382cae498f 100644 --- a/components/com_privacy/models/remind.php +++ b/components/com_privacy/Model/RemindModel.php @@ -7,14 +7,26 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Site\Model; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Table\Table; +use Joomla\CMS\User\UserHelper; +use Joomla\Component\Privacy\Administrator\Table\ConsentTable; +use Joomla\Database\Exception\ExecutionFailureException; + /** * Remind confirmation model class. * * @since 3.9.0 */ -class PrivacyModelRemind extends JModelAdmin +class RemindModel extends AdminModel { /** * Confirms the remind request. @@ -29,10 +41,10 @@ public function remindRequest($data) { // Get the form. $form = $this->getForm(); - $data['email'] = JStringPunycode::emailToPunycode($data['email']); + $data['email'] = PunycodeHelper::emailToPunycode($data['email']); // Check for an error. - if ($form instanceof Exception) + if ($form instanceof \Exception) { return $form; } @@ -42,7 +54,7 @@ public function remindRequest($data) $return = $form->validate($data); // Check for an error. - if ($return instanceof Exception) + if ($return instanceof \Exception) { return $return; } @@ -59,7 +71,7 @@ public function remindRequest($data) return false; } - /** @var PrivacyTableConsent $table */ + /** @var ConsentTable $table */ $table = $this->getTable(); $db = $this->getDbo(); @@ -75,36 +87,36 @@ public function remindRequest($data) { $remind = $db->loadObject(); } - catch (RuntimeException $e) + catch (ExecutionFailureException $e) { - $this->setError(JText::_('COM_PRIVACY_ERROR_NO_PENDING_REMIND')); + $this->setError(Text::_('COM_PRIVACY_ERROR_NO_PENDING_REMIND')); return false; } if (!$remind) { - $this->setError(JText::_('COM_PRIVACY_ERROR_NO_PENDING_REMIND')); + $this->setError(Text::_('COM_PRIVACY_ERROR_NO_PENDING_REMIND')); return false; } // Verify the token - if (!JUserHelper::verifyPassword($data['remind_token'], $remind->token)) + if (!UserHelper::verifyPassword($data['remind_token'], $remind->token)) { - $this->setError(JText::_('COM_PRIVACY_ERROR_NO_REMIND_REQUESTS')); + $this->setError(Text::_('COM_PRIVACY_ERROR_NO_REMIND_REQUESTS')); return false; } // Everything is good to go, transition the request to extended $saved = $this->save( - array( + [ 'id' => $remind->id, 'remind' => 0, 'token' => '', - 'created' => JFactory::getDate()->toSql(), - ) + 'created' => Factory::getDate()->toSql(), + ] ); if (!$saved) @@ -122,21 +134,21 @@ public function remindRequest($data) * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * - * @return JForm|boolean A JForm object on success, false on failure + * @return Form|boolean A Form object on success, false on failure * * @since 3.9.0 */ - public function getForm($data = array(), $loadData = true) + public function getForm($data = [], $loadData = true) { // Get the form. - $form = $this->loadForm('com_privacy.remind', 'remind', array('control' => 'jform')); + $form = $this->loadForm('com_privacy.remind', 'remind', ['control' => 'jform']); if (empty($form)) { return false; } - $input = JFactory::getApplication()->input; + $input = Factory::getApplication()->input; if ($input->getMethod() === 'GET') { @@ -153,12 +165,12 @@ public function getForm($data = array(), $loadData = true) * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * - * @return JTable A JTable object + * @return Table A JTable object * * @since 3.9.0 * @throws \Exception */ - public function getTable($name = 'Consent', $prefix = 'PrivacyTable', $options = array()) + public function getTable($name = 'Consent', $prefix = 'Administrator', $options = []) { return parent::getTable($name, $prefix, $options); } @@ -175,7 +187,7 @@ public function getTable($name = 'Consent', $prefix = 'PrivacyTable', $options = protected function populateState() { // Get the application object. - $params = JFactory::getApplication()->getParams('com_privacy'); + $params = Factory::getApplication()->getParams('com_privacy'); // Load the parameters. $this->setState('params', $params); diff --git a/components/com_privacy/models/request.php b/components/com_privacy/Model/RequestModel.php similarity index 54% rename from components/com_privacy/models/request.php rename to components/com_privacy/Model/RequestModel.php index 0a9f0524bb230..c1766a3ec350b 100644 --- a/components/com_privacy/models/request.php +++ b/components/com_privacy/Model/RequestModel.php @@ -7,50 +7,68 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Site\Model; + defined('_JEXEC') or die; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Router\Route; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\User\UserHelper; +use Joomla\Component\Messages\Administrator\Model\MessageModel; +use Joomla\Component\Privacy\Administrator\Table\RequestTable; +use Joomla\Database\Exception\ExecutionFailureException; +use PHPMailer\PHPMailer\Exception as phpmailerException; + /** * Request model class. * * @since 3.9.0 */ -class PrivacyModelRequest extends JModelAdmin +class RequestModel extends AdminModel { /** * Creates an information request. * * @param array $data The data expected for the form. * - * @return mixed Exception | JException | boolean + * @return mixed Exception | boolean * * @since 3.9.0 */ public function createRequest($data) { // Creating requests requires the site's email sending be enabled - if (!JFactory::getConfig()->get('mailonline', 1)) + if (!Factory::getConfig()->get('mailonline', 1)) { - $this->setError(JText::_('COM_PRIVACY_ERROR_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED')); return false; } // Get the form. - $form = $this->getForm(); - $data['email'] = JStringPunycode::emailToPunycode($data['email']); + $form = $this->getForm(); + $data['email'] = PunycodeHelper::emailToPunycode($data['email']); // Check for an error. - if ($form instanceof Exception) + if ($form instanceof \Exception) { return $form; } // Filter and validate the form data. - $data = $form->filter($data); + $data = $form->filter($data); $return = $form->validate($data); // Check for an error. - if ($return instanceof Exception) + if ($return instanceof \Exception) { return $return; } @@ -68,7 +86,7 @@ public function createRequest($data) } // Search for an open information request matching the email and type - $db = $this->getDbo(); + $db = $this->getDbo(); $query = $db->getQuery(true) ->select('COUNT(id)') ->from('#__privacy_requests') @@ -80,27 +98,27 @@ public function createRequest($data) { $result = (int) $db->setQuery($query)->loadResult(); } - catch (JDatabaseException $exception) + catch (ExecutionFailureException $exception) { // Can't check for existing requests, so don't create a new one - $this->setError(JText::_('COM_PRIVACY_ERROR_CHECKING_FOR_EXISTING_REQUESTS')); + $this->setError(Text::_('COM_PRIVACY_ERROR_CHECKING_FOR_EXISTING_REQUESTS')); return false; } if ($result > 0) { - $this->setError(JText::_('COM_PRIVACY_ERROR_PENDING_REQUEST_OPEN')); + $this->setError(Text::_('COM_PRIVACY_ERROR_PENDING_REQUEST_OPEN')); return false; } // Everything is good to go, create the request - $token = JApplicationHelper::getHash(JUserHelper::genRandomPassword()); - $hashedToken = JUserHelper::hashPassword($token); + $token = ApplicationHelper::getHash(UserHelper::genRandomPassword()); + $hashedToken = UserHelper::hashPassword($token); $data['confirm_token'] = $hashedToken; - $data['confirm_token_created_at'] = JFactory::getDate()->toSql(); + $data['confirm_token_created_at'] = Factory::getDate()->toSql(); if (!$this->save($data)) { @@ -109,49 +127,46 @@ public function createRequest($data) } // Push a notification to the site's super users, deliberately ignoring if this process fails so the below message goes out - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/models', 'MessagesModel'); - JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/tables'); - - /** @var MessagesModelMessage $messageModel */ - $messageModel = JModelLegacy::getInstance('Message', 'MessagesModel'); + /** @var MessageModel $messageModel */ + $messageModel = Factory::getApplication()->bootComponent('com_messages')->getMVCFactory()->createModel('Message', 'Administrator'); $messageModel->notifySuperUsers( - JText::_('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CREATED_REQUEST_SUBJECT'), - JText::sprintf('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CREATED_REQUEST_MESSAGE', $data['email']) + Text::_('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CREATED_REQUEST_SUBJECT'), + Text::sprintf('COM_PRIVACY_ADMIN_NOTIFICATION_USER_CREATED_REQUEST_MESSAGE', $data['email']) ); // The mailer can be set to either throw Exceptions or return boolean false, account for both try { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $linkMode = $app->get('force_ssl', 0) == 2 ? 1 : -1; - $substitutions = array( + $substitutions = [ '[SITENAME]' => $app->get('sitename'), - '[URL]' => JUri::root(), - '[TOKENURL]' => JRoute::link('site', 'index.php?option=com_privacy&view=confirm&confirm_token=' . $token, false, $linkMode), - '[FORMURL]' => JRoute::link('site', 'index.php?option=com_privacy&view=confirm', false, $linkMode), + '[URL]' => Uri::root(), + '[TOKENURL]' => Route::link('site', 'index.php?option=com_privacy&view=confirm&confirm_token=' . $token, false, $linkMode), + '[FORMURL]' => Route::link('site', 'index.php?option=com_privacy&view=confirm', false, $linkMode), '[TOKEN]' => $token, '\\n' => "\n", - ); + ]; switch ($data['request_type']) { case 'export': - $emailSubject = JText::_('COM_PRIVACY_EMAIL_REQUEST_SUBJECT_EXPORT_REQUEST'); - $emailBody = JText::_('COM_PRIVACY_EMAIL_REQUEST_BODY_EXPORT_REQUEST'); + $emailSubject = Text::_('COM_PRIVACY_EMAIL_REQUEST_SUBJECT_EXPORT_REQUEST'); + $emailBody = Text::_('COM_PRIVACY_EMAIL_REQUEST_BODY_EXPORT_REQUEST'); break; case 'remove': - $emailSubject = JText::_('COM_PRIVACY_EMAIL_REQUEST_SUBJECT_REMOVE_REQUEST'); - $emailBody = JText::_('COM_PRIVACY_EMAIL_REQUEST_BODY_REMOVE_REQUEST'); + $emailSubject = Text::_('COM_PRIVACY_EMAIL_REQUEST_SUBJECT_REMOVE_REQUEST'); + $emailBody = Text::_('COM_PRIVACY_EMAIL_REQUEST_BODY_REMOVE_REQUEST'); break; default: - $this->setError(JText::_('COM_PRIVACY_ERROR_UNKNOWN_REQUEST_TYPE')); + $this->setError(Text::_('COM_PRIVACY_ERROR_UNKNOWN_REQUEST_TYPE')); return false; } @@ -162,26 +177,21 @@ public function createRequest($data) $emailBody = str_replace($k, $v, $emailBody); } - $mailer = JFactory::getMailer(); + $mailer = Factory::getMailer(); $mailer->setSubject($emailSubject); $mailer->setBody($emailBody); $mailer->addRecipient($data['email']); $mailResult = $mailer->Send(); - if ($mailResult instanceof JException) - { - // JError was already called so we just need to return now - return false; - } - elseif ($mailResult === false) + if ($mailer->Send() === false) { $this->setError($mailer->ErrorInfo); return false; } - /** @var PrivacyTableRequest $table */ + /** @var RequestTable $table */ $table = $this->getTable(); if (!$table->load($this->getState($this->getName() . '.id'))) @@ -192,19 +202,15 @@ public function createRequest($data) } // Log the request's creation - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); - - $message = array( + $message = [ 'action' => 'request-created', 'requesttype' => $table->request_type, 'subjectemail' => $table->email, 'id' => $table->id, 'itemlink' => 'index.php?option=com_privacy&view=request&id=' . $table->id, - ); + ]; - /** @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog(array($message), 'COM_PRIVACY_ACTION_LOG_CREATED_REQUEST', 'com_privacy.request'); + $this->getActionlogModel()->addLog([$message], 'COM_PRIVACY_ACTION_LOG_CREATED_REQUEST', 'com_privacy.request'); // The email sent and the record is saved, everything is good to go from here return true; @@ -223,13 +229,13 @@ public function createRequest($data) * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * - * @return JForm|boolean A JForm object on success, false on failure + * @return Form|boolean A Form object on success, false on failure * * @since 3.9.0 */ - public function getForm($data = array(), $loadData = true) + public function getForm($data = [], $loadData = true) { - return $this->loadForm('com_privacy.request', 'request', array('control' => 'jform')); + return $this->loadForm('com_privacy.request', 'request', ['control' => 'jform']); } /** @@ -239,12 +245,12 @@ public function getForm($data = array(), $loadData = true) * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * - * @return JTable A JTable object + * @return Table A JTable object * * @since 3.9.0 * @throws \Exception */ - public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = array()) + public function getTable($name = 'Request', $prefix = 'Administrator', $options = []) { return parent::getTable($name, $prefix, $options); } @@ -261,9 +267,23 @@ public function getTable($name = 'Request', $prefix = 'PrivacyTable', $options = protected function populateState() { // Get the application object. - $params = JFactory::getApplication()->getParams('com_privacy'); + $params = Factory::getApplication()->getParams('com_privacy'); // Load the parameters. $this->setState('params', $params); } + + /** + * Method to fetch an instance of the action log model. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function getActionlogModel(): \ActionlogsModelActionlog + { + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel'); + + return BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel'); + } } diff --git a/components/com_privacy/Service/Router.php b/components/com_privacy/Service/Router.php new file mode 100644 index 0000000000000..b6620730676a1 --- /dev/null +++ b/components/com_privacy/Service/Router.php @@ -0,0 +1,49 @@ +registerView(new RouterViewConfiguration('confirm')); + $this->registerView(new RouterViewConfiguration('request')); + $this->registerView(new RouterViewConfiguration('remind')); + + parent::__construct($app, $menu); + + $this->attachRule(new MenuRules($this)); + $this->attachRule(new StandardRules($this)); + $this->attachRule(new NomenuRules($this)); + } +} diff --git a/components/com_privacy/views/confirm/view.html.php b/components/com_privacy/View/Confirm/HtmlView.php similarity index 82% rename from components/com_privacy/views/confirm/view.html.php rename to components/com_privacy/View/Confirm/HtmlView.php index 1e9776d2ec0f0..78f74e254ce7b 100644 --- a/components/com_privacy/views/confirm/view.html.php +++ b/components/com_privacy/View/Confirm/HtmlView.php @@ -7,8 +7,15 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Site\View\Confirm; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Object\CMSObject; use Joomla\Registry\Registry; /** @@ -16,12 +23,12 @@ * * @since 3.9.0 */ -class PrivacyViewConfirm extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The form object * - * @var JForm + * @var Form * @since 3.9.0 */ protected $form; @@ -45,7 +52,7 @@ class PrivacyViewConfirm extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -57,7 +64,7 @@ class PrivacyViewConfirm extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -71,7 +78,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } // Escape strings for HTML output @@ -91,7 +98,7 @@ public function display($tpl = null) */ protected function prepareDocument() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $menus = $app->getMenu(); $title = null; @@ -116,11 +123,11 @@ protected function prepareDocument() } elseif ($app->get('sitename_pagetitles', 0) == 1) { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); + $title = Text::sprintf('JPAGETITLE', $app->get('sitename'), $title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); + $title = Text::sprintf('JPAGETITLE', $title, $app->get('sitename')); } $this->document->setTitle($title); diff --git a/components/com_privacy/views/remind/view.html.php b/components/com_privacy/View/Remind/HtmlView.php similarity index 79% rename from components/com_privacy/views/remind/view.html.php rename to components/com_privacy/View/Remind/HtmlView.php index 6ce0fe083ef8e..050e0884e7898 100644 --- a/components/com_privacy/views/remind/view.html.php +++ b/components/com_privacy/View/Remind/HtmlView.php @@ -7,8 +7,15 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Site\View\Remind; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Object\CMSObject; use Joomla\Registry\Registry; /** @@ -16,12 +23,12 @@ * * @since 3.9.0 */ -class PrivacyViewRemind extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The form object * - * @var JForm + * @var Form * @since 3.9.0 */ protected $form; @@ -45,7 +52,7 @@ class PrivacyViewRemind extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -57,7 +64,7 @@ class PrivacyViewRemind extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -71,7 +78,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } // Escape strings for HTML output @@ -91,7 +98,7 @@ public function display($tpl = null) */ protected function prepareDocument() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $menus = $app->getMenu(); $title = null; @@ -105,7 +112,7 @@ protected function prepareDocument() } else { - $this->params->def('page_heading', JText::_('COM_PRIVACY_VIEW_REMIND_PAGE_TITLE')); + $this->params->def('page_heading', Text::_('COM_PRIVACY_VIEW_REMIND_PAGE_TITLE')); } $title = $this->params->get('page_title', ''); @@ -116,11 +123,11 @@ protected function prepareDocument() } elseif ($app->get('sitename_pagetitles', 0) == 1) { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); + $title = Text::sprintf('JPAGETITLE', $app->get('sitename'), $title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); + $title = Text::sprintf('JPAGETITLE', $title, $app->get('sitename')); } $this->document->setTitle($title); diff --git a/components/com_privacy/views/request/view.html.php b/components/com_privacy/View/Request/HtmlView.php similarity index 78% rename from components/com_privacy/views/request/view.html.php rename to components/com_privacy/View/Request/HtmlView.php index 5013815dadd31..1364b423390f9 100644 --- a/components/com_privacy/views/request/view.html.php +++ b/components/com_privacy/View/Request/HtmlView.php @@ -7,8 +7,15 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Site\View\Request; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Object\CMSObject; use Joomla\Registry\Registry; /** @@ -16,12 +23,12 @@ * * @since 3.9.0 */ -class PrivacyViewRequest extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The form object * - * @var JForm + * @var Form * @since 3.9.0 */ protected $form; @@ -53,7 +60,7 @@ class PrivacyViewRequest extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -65,7 +72,7 @@ class PrivacyViewRequest extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -75,12 +82,12 @@ public function display($tpl = null) $this->form = $this->get('Form'); $this->state = $this->get('State'); $this->params = $this->state->params; - $this->sendMailEnabled = (bool) JFactory::getConfig()->get('mailonline', 1); + $this->sendMailEnabled = (bool) Factory::getConfig()->get('mailonline', 1); // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \JViewGenericdataexception(implode("\n", $errors), 500); } // Escape strings for HTML output @@ -100,7 +107,7 @@ public function display($tpl = null) */ protected function prepareDocument() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $menus = $app->getMenu(); $title = null; @@ -114,7 +121,7 @@ protected function prepareDocument() } else { - $this->params->def('page_heading', JText::_('COM_PRIVACY_VIEW_REQUEST_PAGE_TITLE')); + $this->params->def('page_heading', Text::_('COM_PRIVACY_VIEW_REQUEST_PAGE_TITLE')); } $title = $this->params->get('page_title', ''); @@ -125,11 +132,11 @@ protected function prepareDocument() } elseif ($app->get('sitename_pagetitles', 0) == 1) { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); + $title = Text::sprintf('JPAGETITLE', $app->get('sitename'), $title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); + $title = Text::sprintf('JPAGETITLE', $title, $app->get('sitename')); } $this->document->setTitle($title); diff --git a/components/com_privacy/controllers/request.php b/components/com_privacy/controllers/request.php deleted file mode 100644 index e111401ddb2f5..0000000000000 --- a/components/com_privacy/controllers/request.php +++ /dev/null @@ -1,180 +0,0 @@ -checkToken('post'); - - /** @var PrivacyModelConfirm $model */ - $model = $this->getModel('Confirm', 'PrivacyModel'); - $data = $this->input->post->get('jform', array(), 'array'); - - $return = $model->confirmRequest($data); - - // Check for a hard error. - if ($return instanceof Exception) - { - // Get the error message to display. - if (JFactory::getApplication()->get('error_reporting')) - { - $message = $return->getMessage(); - } - else - { - $message = JText::_('COM_PRIVACY_ERROR_CONFIRMING_REQUEST'); - } - - // Go back to the confirm form. - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=confirm', false), $message, 'error'); - - return false; - } - elseif ($return === false) - { - // Confirm failed. - // Go back to the confirm form. - $message = JText::sprintf('COM_PRIVACY_ERROR_CONFIRMING_REQUEST_FAILED', $model->getError()); - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=confirm', false), $message, 'notice'); - - return false; - } - else - { - // Confirm succeeded. - $this->setRedirect(JRoute::_(JUri::root()), JText::_('COM_PRIVACY_CONFIRM_REQUEST_SUCCEEDED'), 'info'); - - return true; - } - } - - /** - * Method to submit an information request. - * - * @return boolean - * - * @since 3.9.0 - */ - public function submit() - { - // Check the request token. - $this->checkToken('post'); - - /** @var PrivacyModelRequest $model */ - $model = $this->getModel('Request', 'PrivacyModel'); - $data = $this->input->post->get('jform', array(), 'array'); - - $return = $model->createRequest($data); - - // Check for a hard error. - if ($return instanceof Exception) - { - // Get the error message to display. - if (JFactory::getApplication()->get('error_reporting')) - { - $message = $return->getMessage(); - } - else - { - $message = JText::_('COM_PRIVACY_ERROR_CREATING_REQUEST'); - } - - // Go back to the confirm form. - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=request', false), $message, 'error'); - - return false; - } - elseif ($return === false) - { - // Confirm failed. - // Go back to the confirm form. - $message = JText::sprintf('COM_PRIVACY_ERROR_CREATING_REQUEST_FAILED', $model->getError()); - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=request', false), $message, 'notice'); - - return false; - } - else - { - // Confirm succeeded. - $this->setRedirect(JRoute::_(JUri::root()), JText::_('COM_PRIVACY_CREATE_REQUEST_SUCCEEDED'), 'info'); - - return true; - } - } - - /** - * Method to extend the privacy consent. - * - * @return boolean - * - * @since 3.9.0 - */ - public function remind() - { - // Check the request token. - $this->checkToken('post'); - - /** @var PrivacyModelConfirm $model */ - $model = $this->getModel('Remind', 'PrivacyModel'); - $data = $this->input->post->get('jform', array(), 'array'); - - $return = $model->remindRequest($data); - - // Check for a hard error. - if ($return instanceof Exception) - { - // Get the error message to display. - if (JFactory::getApplication()->get('error_reporting')) - { - $message = $return->getMessage(); - } - else - { - $message = JText::_('COM_PRIVACY_ERROR_REMIND_REQUEST'); - } - - // Go back to the confirm form. - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=remind', false), $message, 'error'); - - return false; - } - elseif ($return === false) - { - // Confirm failed. - // Go back to the confirm form. - $message = JText::sprintf('COM_PRIVACY_ERROR_CONFIRMING_REMIND_FAILED', $model->getError()); - $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=remind', false), $message, 'notice'); - - return false; - } - else - { - // Confirm succeeded. - $this->setRedirect(JRoute::_(JUri::root()), JText::_('COM_PRIVACY_CONFIRM_REMIND_SUCCEEDED'), 'info'); - - return true; - } - } -} diff --git a/components/com_privacy/models/forms/confirm.xml b/components/com_privacy/forms/confirm.xml similarity index 100% rename from components/com_privacy/models/forms/confirm.xml rename to components/com_privacy/forms/confirm.xml diff --git a/components/com_privacy/models/forms/remind.xml b/components/com_privacy/forms/remind.xml similarity index 100% rename from components/com_privacy/models/forms/remind.xml rename to components/com_privacy/forms/remind.xml diff --git a/components/com_privacy/models/forms/request.xml b/components/com_privacy/forms/request.xml similarity index 100% rename from components/com_privacy/models/forms/request.xml rename to components/com_privacy/forms/request.xml diff --git a/components/com_privacy/privacy.php b/components/com_privacy/privacy.php deleted file mode 100644 index 48eb01941972c..0000000000000 --- a/components/com_privacy/privacy.php +++ /dev/null @@ -1,14 +0,0 @@ -execute(JFactory::getApplication()->input->get('task')); -$controller->redirect(); diff --git a/components/com_privacy/router.php b/components/com_privacy/router.php deleted file mode 100644 index 2574acc212780..0000000000000 --- a/components/com_privacy/router.php +++ /dev/null @@ -1,78 +0,0 @@ -registerView(new JComponentRouterViewconfiguration('confirm')); - $this->registerView(new JComponentRouterViewconfiguration('request')); - $this->registerView(new JComponentRouterViewconfiguration('remind')); - - parent::__construct($app, $menu); - - $this->attachRule(new JComponentRouterRulesMenu($this)); - $this->attachRule(new JComponentRouterRulesStandard($this)); - $this->attachRule(new JComponentRouterRulesNomenu($this)); - } -} - -/** - * Privacy router functions - * - * These functions are proxies for the new router interface - * for old SEF extensions. - * - * @param array &$query REQUEST query - * - * @return array Segments of the SEF url - * - * @since 3.9.0 - * @deprecated 4.0 Use Class based routers instead - */ -function privacyBuildRoute(&$query) -{ - $app = JFactory::getApplication(); - $router = new PrivacyRouter($app, $app->getMenu()); - - return $router->build($query); -} - -/** - * Convert SEF URL segments into query variables - * - * @param array $segments Segments in the current URL - * - * @return array Query variables - * - * @since 3.9.0 - * @deprecated 4.0 Use Class based routers instead - */ -function privacyParseRoute($segments) -{ - $app = JFactory::getApplication(); - $router = new PrivacyRouter($app, $app->getMenu()); - - return $router->parse($segments); -} diff --git a/components/com_privacy/views/confirm/tmpl/default.php b/components/com_privacy/tmpl/confirm/default.php similarity index 100% rename from components/com_privacy/views/confirm/tmpl/default.php rename to components/com_privacy/tmpl/confirm/default.php diff --git a/components/com_privacy/views/confirm/tmpl/default.xml b/components/com_privacy/tmpl/confirm/default.xml similarity index 100% rename from components/com_privacy/views/confirm/tmpl/default.xml rename to components/com_privacy/tmpl/confirm/default.xml diff --git a/components/com_privacy/views/remind/tmpl/default.php b/components/com_privacy/tmpl/remind/default.php similarity index 100% rename from components/com_privacy/views/remind/tmpl/default.php rename to components/com_privacy/tmpl/remind/default.php diff --git a/components/com_privacy/views/remind/tmpl/default.xml b/components/com_privacy/tmpl/remind/default.xml similarity index 100% rename from components/com_privacy/views/remind/tmpl/default.xml rename to components/com_privacy/tmpl/remind/default.xml diff --git a/components/com_privacy/views/request/tmpl/default.php b/components/com_privacy/tmpl/request/default.php similarity index 100% rename from components/com_privacy/views/request/tmpl/default.php rename to components/com_privacy/tmpl/request/default.php diff --git a/components/com_privacy/views/request/tmpl/default.xml b/components/com_privacy/tmpl/request/default.xml similarity index 100% rename from components/com_privacy/views/request/tmpl/default.xml rename to components/com_privacy/tmpl/request/default.xml diff --git a/libraries/extensions.classmap.php b/libraries/extensions.classmap.php index 25b50fe39a702..cb8108ba7b5b1 100644 --- a/libraries/extensions.classmap.php +++ b/libraries/extensions.classmap.php @@ -13,4 +13,11 @@ JLoader::registerAlias('FieldsPlugin', '\\Joomla\\Component\\Fields\\Administrator\\Plugin\\FieldsPlugin', '4.0'); JLoader::registerAlias('FieldsListPlugin', '\\Joomla\\Component\\Fields\\Administrator\\Plugin\\FieldsListPlugin', '4.0'); +JLoader::registerAlias('PrivacyExportDomain', '\\Joomla\\Component\\Privacy\\Administrator\\Export\\Domain', '5.0'); +JLoader::registerAlias('PrivacyExportField', '\\Joomla\\Component\\Privacy\\Administrator\\Export\\Field', '5.0'); +JLoader::registerAlias('PrivacyExportItem', '\\Joomla\\Component\\Privacy\\Administrator\\Export\\Item', '5.0'); +JLoader::registerAlias('PrivacyPlugin', '\\Joomla\\Component\\Privacy\\Administrator\\Plugin\\PrivacyPlugin', '5.0'); +JLoader::registerAlias('PrivacyRemovalStatus', '\\Joomla\\Component\\Privacy\\Administrator\\Removal\\Status', '5.0'); +JLoader::registerAlias('PrivacyTableRequest', '\\Joomla\\Component\\Privacy\\Administrator\\Table\\RequestTable', '5.0'); + JLoader::registerAlias('TagsTableTag', '\\Joomla\\Component\\Tags\\Administrator\\Table\\TagTable', '4.0'); diff --git a/plugins/privacy/actionlogs/actionlogs.php b/plugins/privacy/actionlogs/actionlogs.php index 6da940991da7d..1a85affd0454c 100644 --- a/plugins/privacy/actionlogs/actionlogs.php +++ b/plugins/privacy/actionlogs/actionlogs.php @@ -10,8 +10,6 @@ defined('_JEXEC') or die; JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php'); -JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); -JLoader::register('PrivacyTableRequest', JPATH_ADMINISTRATOR . '/components/com_privacy/tables/request.php'); /** * Privacy plugin managing Joomla actionlogs data diff --git a/plugins/privacy/consents/consents.php b/plugins/privacy/consents/consents.php index de3819e230fe4..7e1f542fe9bf4 100644 --- a/plugins/privacy/consents/consents.php +++ b/plugins/privacy/consents/consents.php @@ -9,8 +9,6 @@ defined('_JEXEC') or die; -JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); - /** * Privacy plugin managing Joomla user consent data * diff --git a/plugins/privacy/contact/contact.php b/plugins/privacy/contact/contact.php index ee72051987605..0713353ed9531 100644 --- a/plugins/privacy/contact/contact.php +++ b/plugins/privacy/contact/contact.php @@ -9,9 +9,6 @@ defined('_JEXEC') or die; -JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); -JLoader::register('PrivacyTableRequest', JPATH_ADMINISTRATOR . '/components/com_privacy/tables/request.php'); - /** * Privacy plugin managing Joomla user contact data * diff --git a/plugins/privacy/content/content.php b/plugins/privacy/content/content.php index 3a9ec5c305eb0..2bdd982032f46 100644 --- a/plugins/privacy/content/content.php +++ b/plugins/privacy/content/content.php @@ -9,9 +9,6 @@ defined('_JEXEC') or die; -JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); -JLoader::register('PrivacyTableRequest', JPATH_ADMINISTRATOR . '/components/com_privacy/tables/request.php'); - /** * Privacy plugin managing Joomla user content data * diff --git a/plugins/privacy/message/message.php b/plugins/privacy/message/message.php index cdcd5d2f258b3..583a2484456e2 100644 --- a/plugins/privacy/message/message.php +++ b/plugins/privacy/message/message.php @@ -9,9 +9,6 @@ defined('_JEXEC') or die; -JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); -JLoader::register('PrivacyTableRequest', JPATH_ADMINISTRATOR . '/components/com_privacy/tables/request.php'); - /** * Privacy plugin managing Joomla user messages * diff --git a/plugins/privacy/user/user.php b/plugins/privacy/user/user.php index 5bc2475fd2058..a2c1b34bf7659 100644 --- a/plugins/privacy/user/user.php +++ b/plugins/privacy/user/user.php @@ -11,10 +11,6 @@ use Joomla\Utilities\ArrayHelper; -JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); -JLoader::register('PrivacyRemovalStatus', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/removal/status.php'); -JLoader::register('PrivacyTableRequest', JPATH_ADMINISTRATOR . '/components/com_privacy/tables/request.php'); - /** * Privacy plugin managing Joomla user data *