[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  /**
   3   * @package     Joomla.Plugin
   4   * @subpackage  Privacy.actionlogs
   5   *
   6   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  defined('_JEXEC') or die;
  11  
  12  use Joomla\CMS\User\User;
  13  use Joomla\Component\Actionlogs\Administrator\Helper\ActionlogsHelper;
  14  use Joomla\Component\Privacy\Administrator\Plugin\PrivacyPlugin;
  15  use Joomla\Component\Privacy\Administrator\Table\RequestTable;
  16  use Joomla\Database\ParameterType;
  17  
  18  /**
  19   * Privacy plugin managing Joomla actionlogs data
  20   *
  21   * @since  3.9.0
  22   */
  23  class PlgPrivacyActionlogs extends PrivacyPlugin
  24  {
  25      /**
  26       * Processes an export request for Joomla core actionlog data
  27       *
  28       * @param   RequestTable  $request  The request record being processed
  29       * @param   User          $user     The user account associated with this request if available
  30       *
  31       * @return  \Joomla\Component\Privacy\Administrator\Export\Domain[]
  32       *
  33       * @since   3.9.0
  34       */
  35  	public function onPrivacyExportRequest(RequestTable $request, User $user = null)
  36      {
  37          if (!$user)
  38          {
  39              return array();
  40          }
  41  
  42          $domain = $this->createDomain('user_action_logs', 'joomla_user_action_logs_data');
  43          $db     = $this->db;
  44          $userId = (int) $user->id;
  45  
  46          $query = $db->getQuery(true)
  47              ->select(['a.*', $db->quoteName('u.name')])
  48              ->from($db->quoteName('#__action_logs', 'a'))
  49              ->join('INNER', $db->quoteName('#__users', 'u'), $db->quoteName('a.user_id') . ' = ' . $db->quoteName('u.id'))
  50              ->where($db->quoteName('a.user_id') . ' = :id')
  51              ->bind(':id', $userId, ParameterType::INTEGER);
  52  
  53          $db->setQuery($query);
  54  
  55          $data = $db->loadObjectList();
  56  
  57          if (!count($data))
  58          {
  59              return array();
  60          }
  61  
  62          $data    = ActionlogsHelper::getCsvData($data);
  63          $isFirst = true;
  64  
  65          foreach ($data as $item)
  66          {
  67              if ($isFirst)
  68              {
  69                  $isFirst = false;
  70  
  71                  continue;
  72              }
  73  
  74              $domain->addItem($this->createItemFromArray($item));
  75          }
  76  
  77          return array($domain);
  78      }
  79  }


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