[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/privacy/consents/ -> consents.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Privacy.consents
   6   *
   7   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9  
  10   * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
  11   */
  12  
  13  use Joomla\CMS\User\User;
  14  use Joomla\Component\Privacy\Administrator\Plugin\PrivacyPlugin;
  15  use Joomla\Component\Privacy\Administrator\Table\RequestTable;
  16  use Joomla\Database\ParameterType;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Privacy plugin managing Joomla user consent data
  24   *
  25   * @since  3.9.0
  26   */
  27  class PlgPrivacyConsents extends PrivacyPlugin
  28  {
  29      /**
  30       * Processes an export request for Joomla core user consent data
  31       *
  32       * This event will collect data for the core `#__privacy_consents` table
  33       *
  34       * @param   RequestTable  $request  The request record being processed
  35       * @param   User          $user     The user account associated with this request if available
  36       *
  37       * @return  \Joomla\Component\Privacy\Administrator\Export\Domain[]
  38       *
  39       * @since   3.9.0
  40       */
  41      public function onPrivacyExportRequest(RequestTable $request, User $user = null)
  42      {
  43          if (!$user) {
  44              return array();
  45          }
  46  
  47          $domain = $this->createDomain('consents', 'joomla_consent_data');
  48          $db     = $this->db;
  49  
  50          $query = $db->getQuery(true)
  51              ->select('*')
  52              ->from($db->quoteName('#__privacy_consents'))
  53              ->where($db->quoteName('user_id') . ' = :id')
  54              ->order($db->quoteName('created') . ' ASC')
  55              ->bind(':id', $user->id, ParameterType::INTEGER);
  56  
  57          $items = $db->setQuery($query)->loadAssocList();
  58  
  59          foreach ($items as $item) {
  60              $domain->addItem($this->createItemFromArray($item));
  61          }
  62  
  63          return array($domain);
  64      }
  65  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer