diff --git a/administrator/components/com_actionlogs/libraries/actionlogplugin.php b/administrator/components/com_actionlogs/libraries/actionlogplugin.php new file mode 100644 index 0000000000000..e9e1819829a77 --- /dev/null +++ b/administrator/components/com_actionlogs/libraries/actionlogplugin.php @@ -0,0 +1,98 @@ + $message) + { + if (!array_key_exists('userid', $message)) + { + $message['userid'] = $user->id; + } + + if (!array_key_exists('username', $message)) + { + $message['username'] = $user->username; + } + + if (!array_key_exists('accountlink', $message)) + { + $message['accountlink'] = 'index.php?option=com_users&task=user.edit&id=' . $user->id; + } + + if (array_key_exists('type', $message)) + { + $message['type'] = strtoupper($message['type']); + } + + if (array_key_exists('app', $message)) + { + $message['app'] = strtoupper($message['app']); + } + + $messages[$index] = $message; + } + + /** @var ActionlogsModelActionlog $model **/ + $model = BaseModel::getInstance('Actionlog', 'ActionlogsModel'); + $model->addLog($messages, strtoupper($messageLanguageKey), $context, $userId); + } +} diff --git a/administrator/components/com_actionlogs/models/fields/logtype.php b/administrator/components/com_actionlogs/models/fields/logtype.php index 8573ae9ca781b..c8f0ef56b08e5 100644 --- a/administrator/components/com_actionlogs/models/fields/logtype.php +++ b/administrator/components/com_actionlogs/models/fields/logtype.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +use Joomla\CMS\Application\ApplicationHelper; + JFormHelper::loadFieldClass('checkboxes'); JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php'); @@ -38,29 +40,23 @@ public function getOptions() { $db = JFactory::getDbo(); $query = $db->getQuery(true) - ->select('a.extension') - ->from($db->quoteName('#__action_logs_extensions', 'a')); - - $db->setQuery($query); + ->select($db->quoteName('extension')) + ->from($db->quoteName('#__action_logs_extensions')); - $extensions = $db->loadObjectList(); + $extensions = $db->setQuery($query)->loadColumn(); - $options = array(); - $defaults = array(); + $options = array(); + $tmp = array('checked' => true); foreach ($extensions as $extension) { - $tmp = array( - 'checked' => true, - ); - - $defaults[] = $extension; - - ActionlogsHelper::loadTranslationFiles($extension->extension); - $option = JHtml::_('select.option', $extension->extension, JText::_($extension->extension)); - $options[] = (object) array_merge($tmp, (array) $option); + ActionlogsHelper::loadTranslationFiles($extension); + $option = JHtml::_('select.option', $extension, JText::_($extension)); + $options[ApplicationHelper::stringURLSafe(JText::_($extension)) . '_' . $extension] = (object) array_merge($tmp, (array) $option); } - return array_merge(parent::getOptions(), $options); + ksort($options); + + return array_merge(parent::getOptions(), array_values($options)); } } diff --git a/administrator/components/com_associations/tmpl/associations/default.php b/administrator/components/com_associations/tmpl/associations/default.php index c0580a82d07d6..533c4c91a5469 100644 --- a/administrator/components/com_associations/tmpl/associations/default.php +++ b/administrator/components/com_associations/tmpl/associations/default.php @@ -94,29 +94,31 @@ - level)) : ?> - $item->level)); ?> - - - editor, $item->checked_out_time, 'associations.', $canCheckin); ?> - - - '; ?> - - escape($item->title); ?> - - escape($item->title); ?> - - typeFields['alias'])) : ?> - - escape($item->alias)); ?> - - - typeFields['catid'])) : ?> -
- escape($item->category_title); ?> -
- +
+ level)) : ?> + $item->level)); ?> + + + editor, $item->checked_out_time, 'associations.', $canCheckin); ?> + + + '; ?> + + escape($item->title); ?> + + escape($item->title); ?> + + typeFields['alias'])) : ?> + + escape($item->alias)); ?> + + + typeFields['catid'])) : ?> +
+ escape($item->category_title); ?> +
+ +
diff --git a/administrator/components/com_banners/tmpl/banners/default_batch_footer.php b/administrator/components/com_banners/tmpl/banners/default_batch_footer.php index 0dab78da46c71..3c491481c34f5 100644 --- a/administrator/components/com_banners/tmpl/banners/default_batch_footer.php +++ b/administrator/components/com_banners/tmpl/banners/default_batch_footer.php @@ -12,9 +12,9 @@ use Joomla\CMS\Language\Text; ?> - + + diff --git a/administrator/components/com_categories/tmpl/categories/default_batch_footer.php b/administrator/components/com_categories/tmpl/categories/default_batch_footer.php index 5124624002b65..a0ebaf58d232e 100644 --- a/administrator/components/com_categories/tmpl/categories/default_batch_footer.php +++ b/administrator/components/com_categories/tmpl/categories/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - + + \ No newline at end of file + diff --git a/administrator/components/com_contact/tmpl/contacts/default_batch_footer.php b/administrator/components/com_contact/tmpl/contacts/default_batch_footer.php index e5f7817d5bb7a..91b16f3725762 100644 --- a/administrator/components/com_contact/tmpl/contacts/default_batch_footer.php +++ b/administrator/components/com_contact/tmpl/contacts/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - + + \ No newline at end of file + diff --git a/administrator/components/com_content/tmpl/articles/default_batch_footer.php b/administrator/components/com_content/tmpl/articles/default_batch_footer.php index de65d2767d6ad..041a84863a67a 100644 --- a/administrator/components/com_content/tmpl/articles/default_batch_footer.php +++ b/administrator/components/com_content/tmpl/articles/default_batch_footer.php @@ -13,9 +13,9 @@ HTMLHelper::_('script', 'com_content/admin-articles-default-batch-footer.js', ['version' => 'auto', 'relative' => true]); ?> - - diff --git a/administrator/components/com_fields/tmpl/fields/default_batch_footer.php b/administrator/components/com_fields/tmpl/fields/default_batch_footer.php index 9cf6f54a40838..9ae14560a39fe 100644 --- a/administrator/components/com_fields/tmpl/fields/default_batch_footer.php +++ b/administrator/components/com_fields/tmpl/fields/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - - \ No newline at end of file + diff --git a/administrator/components/com_fields/tmpl/groups/default_batch_footer.php b/administrator/components/com_fields/tmpl/groups/default_batch_footer.php index 18ef50e4bef65..86dca38324298 100644 --- a/administrator/components/com_fields/tmpl/groups/default_batch_footer.php +++ b/administrator/components/com_fields/tmpl/groups/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - - \ No newline at end of file + diff --git a/administrator/components/com_menus/tmpl/items/default_batch_footer.php b/administrator/components/com_menus/tmpl/items/default_batch_footer.php index 04f9eec478588..588ae910a5775 100644 --- a/administrator/components/com_menus/tmpl/items/default_batch_footer.php +++ b/administrator/components/com_menus/tmpl/items/default_batch_footer.php @@ -15,11 +15,11 @@ $clientId = $this->state->get('filter.client_id'); $menuType = Factory::getApplication()->getUserState('com_menus.items.menutype'); ?> - + 0 && $clientId == 1)): ?> - diff --git a/administrator/components/com_modules/tmpl/modules/default_batch_footer.php b/administrator/components/com_modules/tmpl/modules/default_batch_footer.php index 8804af7ccaff5..db42ddf3c86b5 100644 --- a/administrator/components/com_modules/tmpl/modules/default_batch_footer.php +++ b/administrator/components/com_modules/tmpl/modules/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - + + \ No newline at end of file + diff --git a/administrator/components/com_newsfeeds/tmpl/newsfeeds/default_batch_footer.php b/administrator/components/com_newsfeeds/tmpl/newsfeeds/default_batch_footer.php index 35800e68d6309..4d93245455359 100644 --- a/administrator/components/com_newsfeeds/tmpl/newsfeeds/default_batch_footer.php +++ b/administrator/components/com_newsfeeds/tmpl/newsfeeds/default_batch_footer.php @@ -12,9 +12,9 @@ use Joomla\CMS\Language\Text; ?> - + + \ No newline at end of file + diff --git a/administrator/components/com_privacy/helpers/plugin.php b/administrator/components/com_privacy/helpers/plugin.php index ddf4196571e23..0a0a329d9305a 100644 --- a/administrator/components/com_privacy/helpers/plugin.php +++ b/administrator/components/com_privacy/helpers/plugin.php @@ -12,6 +12,7 @@ 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'); /** * Base class for privacy plugins @@ -20,6 +21,22 @@ */ abstract class PrivacyPlugin extends JPlugin { + /** + * Database object + * + * @var JDatabaseDriver + * @since 3.9.0 + */ + protected $db; + + /** + * Affects constructor behaviour. If true, language files will be loaded automatically. + * + * @var boolean + * @since 3.9.0 + */ + protected $autoloadLanguage = true; + /** * Create a new domain object * @@ -96,4 +113,47 @@ protected function createItemForTable($table) return $this->createItemFromArray($data, $table->{$table->getKeyName(false)}); } + + /** + * Helper function to create the domain for the items custom fields. + * + * @param string $context The context + * @param stdClass $item The items + * + * @return PrivacyExportDomain + * + * @since 3.9.0 + */ + protected function createCustomFieldsDomain($context, $item) + { + $parts = FieldsHelper::extract($context); + + if (!$parts) + { + return array(); + } + + $type = str_replace('com_', '', $parts[0]); + + $domain = $this->createDomain($type . '_custom_fields', 'joomla_' . $type . '_custom_fields_data'); + + // Get item's fields, also preparing their value property for manual display + $fields = FieldsHelper::getFields($parts[0] . '.' . $parts[1], $item); + + foreach ($fields as $field) + { + $fieldValue = is_array($field->value) ? implode(', ', $field->value) : $field->value; + + $data = array( + $type . '_id' => $item->id, + 'field_name' => $field->name, + 'field_title' => $field->title, + 'field_value' => $fieldValue, + ); + + $domain->addItem($this->createItemFromArray($data)); + } + + return $domain; + } } diff --git a/administrator/components/com_redirect/tmpl/links/default_batch_footer.php b/administrator/components/com_redirect/tmpl/links/default_batch_footer.php index 28e385b6f12dc..e96641eff2cfe 100644 --- a/administrator/components/com_redirect/tmpl/links/default_batch_footer.php +++ b/administrator/components/com_redirect/tmpl/links/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - + + diff --git a/administrator/components/com_tags/tmpl/tags/default_batch_footer.php b/administrator/components/com_tags/tmpl/tags/default_batch_footer.php index dca02b758a666..a1d78e7df89e6 100644 --- a/administrator/components/com_tags/tmpl/tags/default_batch_footer.php +++ b/administrator/components/com_tags/tmpl/tags/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - + + \ No newline at end of file + diff --git a/administrator/components/com_templates/tmpl/template/default_modal_copy_footer.php b/administrator/components/com_templates/tmpl/template/default_modal_copy_footer.php index 8f1d3d8ef531f..6df3b0d72d450 100644 --- a/administrator/components/com_templates/tmpl/template/default_modal_copy_footer.php +++ b/administrator/components/com_templates/tmpl/template/default_modal_copy_footer.php @@ -12,5 +12,5 @@ use Joomla\CMS\Language\Text; ?> - - + + diff --git a/administrator/components/com_templates/tmpl/template/default_modal_delete_footer.php b/administrator/components/com_templates/tmpl/template/default_modal_delete_footer.php index 740cfeb821d7a..9382c9a39a171 100644 --- a/administrator/components/com_templates/tmpl/template/default_modal_delete_footer.php +++ b/administrator/components/com_templates/tmpl/template/default_modal_delete_footer.php @@ -21,6 +21,6 @@ - + diff --git a/administrator/components/com_templates/tmpl/template/default_modal_file_footer.php b/administrator/components/com_templates/tmpl/template/default_modal_file_footer.php index 4372335d36982..810ad8f291d10 100644 --- a/administrator/components/com_templates/tmpl/template/default_modal_file_footer.php +++ b/administrator/components/com_templates/tmpl/template/default_modal_file_footer.php @@ -12,4 +12,4 @@ use Joomla\CMS\Language\Text; ?> - + diff --git a/administrator/components/com_templates/tmpl/template/default_modal_folder_footer.php b/administrator/components/com_templates/tmpl/template/default_modal_folder_footer.php index 024cdc54dd5f5..c23b86e870a03 100644 --- a/administrator/components/com_templates/tmpl/template/default_modal_folder_footer.php +++ b/administrator/components/com_templates/tmpl/template/default_modal_folder_footer.php @@ -18,7 +18,7 @@ ?>
- + diff --git a/administrator/components/com_templates/tmpl/template/default_modal_rename_footer.php b/administrator/components/com_templates/tmpl/template/default_modal_rename_footer.php index 7ec9daf352dbc..c94b60a8493cc 100644 --- a/administrator/components/com_templates/tmpl/template/default_modal_rename_footer.php +++ b/administrator/components/com_templates/tmpl/template/default_modal_rename_footer.php @@ -12,5 +12,5 @@ use Joomla\CMS\Language\Text; ?> - - + + diff --git a/administrator/components/com_templates/tmpl/template/default_modal_resize_footer.php b/administrator/components/com_templates/tmpl/template/default_modal_resize_footer.php index 0c3d33fa683b9..25b0a77df46f3 100644 --- a/administrator/components/com_templates/tmpl/template/default_modal_resize_footer.php +++ b/administrator/components/com_templates/tmpl/template/default_modal_resize_footer.php @@ -12,5 +12,5 @@ use Joomla\CMS\Language\Text; ?> - - + + diff --git a/administrator/components/com_users/tmpl/users/default_batch_footer.php b/administrator/components/com_users/tmpl/users/default_batch_footer.php index ee7443585aaca..a0170dc243e9c 100644 --- a/administrator/components/com_users/tmpl/users/default_batch_footer.php +++ b/administrator/components/com_users/tmpl/users/default_batch_footer.php @@ -11,9 +11,9 @@ use Joomla\CMS\Language\Text; ?> - + + \ No newline at end of file + diff --git a/administrator/language/en-GB/en-GB.com_associations.ini b/administrator/language/en-GB/en-GB.com_associations.ini index 17f62614d67e6..14898e17551dd 100644 --- a/administrator/language/en-GB/en-GB.com_associations.ini +++ b/administrator/language/en-GB/en-GB.com_associations.ini @@ -18,6 +18,7 @@ COM_ASSOCIATIONS_EDIT_ASSOCIATION="Edit association" COM_ASSOCIATIONS_EDIT_HIDE_REFERENCE="Hide Reference" COM_ASSOCIATIONS_EDIT_SHOW_REFERENCE="Show Reference" COM_ASSOCIATIONS_ERROR_NO_ASSOC="The Multilingual Associations component can't be used if the site is not set as multilingual and/or Associations is not enabled in the Language Filter plugin." +COM_ASSOCIATIONS_ERROR_NO_TYPE="The item type selected does not exist for this component." COM_ASSOCIATIONS_FILTER_SEARCH_DESC="Search an item by its title" COM_ASSOCIATIONS_FILTER_SEARCH_LABEL="Search item" COM_ASSOCIATIONS_FILTER_SELECT_ITEM_TYPE="- Select Item Type -" diff --git a/components/com_mailto/Controller/DisplayController.php b/components/com_mailto/Controller/DisplayController.php index 161a82f70d3fe..87e973174c491 100644 --- a/components/com_mailto/Controller/DisplayController.php +++ b/components/com_mailto/Controller/DisplayController.php @@ -101,7 +101,7 @@ public function send() { foreach ($headers as $header) { - if (strpos($value, $header) !== false) + if (is_string($value) && strpos($value, $header) !== false) { throw new \Exception('', 403); } diff --git a/components/com_mailto/Model/MailtoModel.php b/components/com_mailto/Model/MailtoModel.php index 873922c9de849..a8f78cb644dd4 100644 --- a/components/com_mailto/Model/MailtoModel.php +++ b/components/com_mailto/Model/MailtoModel.php @@ -100,10 +100,11 @@ public function getData() { $input = Factory::getApplication()->input; - $data['emailto'] = $input->get('emailto', '', 'string'); - $data['sender'] = $input->get('sender', '', 'string'); - $data['emailfrom'] = $input->get('emailfrom', '', 'string'); - $data['subject'] = $input->get('subject', '', 'string'); + $data['emailto'] = $input->get('emailto', '', 'string'); + $data['sender'] = $input->get('sender', '', 'string'); + $data['emailfrom'] = $input->get('emailfrom', '', 'string'); + $data['subject'] = $input->get('subject', '', 'string'); + $data['consentbox'] = $input->get('consentbox', '', 'string'); return $data; } diff --git a/components/com_users/Model/RegistrationModel.php b/components/com_users/Model/RegistrationModel.php index 3fa5c6f286e5f..8495db5d15197 100644 --- a/components/com_users/Model/RegistrationModel.php +++ b/components/com_users/Model/RegistrationModel.php @@ -70,7 +70,7 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu * * @return mixed False on failure, id of the user on success * - * @since 4.0.0 + * @since 3.8.13 */ public function getUserIdFromToken($token) { diff --git a/language/en-GB/en-GB.com_content.ini b/language/en-GB/en-GB.com_content.ini index bf3388b942baa..069aa8c40f8ae 100644 --- a/language/en-GB/en-GB.com_content.ini +++ b/language/en-GB/en-GB.com_content.ini @@ -6,8 +6,8 @@ COM_CONTENT_ARTICLE_CONTENT="Content" COM_CONTENT_ARTICLE_HITS="Hits: %s" COM_CONTENT_ARTICLE_INFO="Details" -COM_CONTENT_ARTICLE_VOTE_FAILURE="You already rated this Article today!" -COM_CONTENT_ARTICLE_VOTE_SUCCESS="Thank You for rating this Article." +COM_CONTENT_ARTICLE_VOTE_FAILURE="You already rated this article today!" +COM_CONTENT_ARTICLE_VOTE_SUCCESS="Thank you for rating this article." COM_CONTENT_AUTHOR_FILTER_LABEL="Author Filter" COM_CONTENT_CAPTCHA_DESC="Please complete the security check." COM_CONTENT_CAPTCHA_LABEL="Captcha" diff --git a/language/en-GB/en-GB.com_users.ini b/language/en-GB/en-GB.com_users.ini index 96b864e54b034..a79110d59979c 100644 --- a/language/en-GB/en-GB.com_users.ini +++ b/language/en-GB/en-GB.com_users.ini @@ -93,7 +93,7 @@ COM_USERS_REGISTER_USERNAME_LABEL="Username" COM_USERS_REGISTER_USERNAME_MESSAGE="The username you entered is not available. Please pick another username." COM_USERS_REGISTRATION="User Registration" COM_USERS_REGISTRATION_ACL_ADMIN_ACTIVATION="Please log in to confirm that you are authorised to activate new accounts." -COM_USERS_REGISTRATION_ACL_ADMIN_ACTIVATION_PERMISSIONS="You are not authorised to activate new accounts, please login with a privileged account." +COM_USERS_REGISTRATION_ACL_ADMIN_ACTIVATION_PERMISSIONS="You are not authorised to activate new accounts, please log in with a privileged account." COM_USERS_REGISTRATION_ACTIVATE_SUCCESS="Your Account has been activated. You can now log in using the username and password you chose during the registration." COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED="An error was encountered while sending activation notification email" COM_USERS_REGISTRATION_ACTIVATION_SAVE_FAILED="Failed to save activation data: %s" diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index 4daf84b91e478..6ec12f6ef7bd0 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -34,6 +34,7 @@ use Joomla\DI\ContainerAwareInterface; use Joomla\DI\ContainerAwareTrait; use Joomla\Registry\Registry; +use Joomla\String\StringHelper; /** * Joomla! CMS Application class @@ -998,6 +999,42 @@ protected function route() $router = static::getRouter(); $result = $router->parse($uri, true); + $active = $this->getMenu()->getActive(); + + if ($active !== null && $active->type === 'alias') + { + $item = $this->getMenu()->getItem($active->params->get('aliasoptions')); + + if ($item !== null) + { + $oldUri = clone \JUri::getInstance(); + + if ($oldUri->getVar('Itemid') == $active->id) + { + $oldUri->setVar('Itemid', $item->id); + } + + $base = \JUri::base(true); + $oldPath = StringHelper::strtolower(substr($oldUri->getPath(), strlen($base) + 1)); + $activePathPrefix = StringHelper::strtolower($active->route); + + $position = strpos($oldPath, $activePathPrefix); + + if ($position !== false) + { + $oldUri->setPath($base . '/' . substr_replace($oldPath, $item->route, $position, strlen($activePathPrefix))); + + $this->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true); + $this->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true); + $this->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false); + $this->setHeader('Pragma', 'no-cache'); + $this->sendHeaders(); + + $this->redirect((string) $oldUri, 301); + } + } + } + foreach ($result as $key => $value) { $this->input->def($key, $value); diff --git a/modules/mod_whosonline/Helper/WhosonlineHelper.php b/modules/mod_whosonline/Helper/WhosonlineHelper.php index 9e6859a8721f6..1a93e206e9495 100644 --- a/modules/mod_whosonline/Helper/WhosonlineHelper.php +++ b/modules/mod_whosonline/Helper/WhosonlineHelper.php @@ -50,7 +50,6 @@ public static function getOnlineCount() } catch (\RuntimeException $e) { - // Don't worry be happy $sessions = []; } diff --git a/plugins/actionlog/joomla/joomla.php b/plugins/actionlog/joomla/joomla.php index 11a9a6ea07e5c..a745c302f67d7 100644 --- a/plugins/actionlog/joomla/joomla.php +++ b/plugins/actionlog/joomla/joomla.php @@ -12,6 +12,7 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\Utilities\ArrayHelper; +JLoader::register('ActionLogPlugin', JPATH_ADMINISTRATOR . '/components/com_actionlogs/libraries/actionlogplugin.php'); JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php'); /** @@ -19,7 +20,7 @@ * * @since 3.9.0 */ -class PlgActionlogJoomla extends JPlugin +class PlgActionlogJoomla extends ActionLogPlugin { /** * Array of loggable extensions. @@ -30,28 +31,12 @@ class PlgActionlogJoomla extends JPlugin protected $loggableExtensions = array(); /** - * Application object. + * Context aliases * - * @var JApplicationCms - * @since 3.9.0 - */ - protected $app; - - /** - * Database object. - * - * @var JDatabaseDriver - * @since 3.9.0 - */ - protected $db; - - /** - * Load plugin language file automatically so that it can be used inside component - * - * @var boolean - * @since 3.9.0 + * @var array + * @since 3.9.0 */ - protected $autoloadLanguage = true; + protected $contextAliases = array('com_content.form' => 'com_content.article'); /** * Constructor. @@ -85,6 +70,11 @@ public function __construct(&$subject, $config) */ public function onContentAfterSave($context, $article, $isNew) { + if (isset($this->contextAliases[$context])) + { + $context = $this->contextAliases[$context]; + } + $option = $this->app->input->getCmd('option'); if (!$this->checkLoggable($option)) @@ -100,27 +90,21 @@ public function onContentAfterSave($context, $article, $isNew) return; } - $user = JFactory::getUser(); - $contentTypeTitle = strtoupper($params->type_title); list(, $contentType) = explode('.', $params->type_alias); if ($isNew) { - $messageLanguageKey = strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_ADDED'); - $defaultLanguageKey = strtoupper('PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'); - - $action = 'add'; + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_ADDED'; + $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'; } else { - $messageLanguageKey = strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_UPDATED'); - $defaultLanguageKey = strtoupper('PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED'); - - $action = 'update'; + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_UPDATED'; + $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED'; } // If the content type doesn't has it own language key, use default language key - if (!JFactory::getLanguage()->hasKey($messageLanguageKey)) + if (!$this->app->getLanguage()->hasKey($messageLanguageKey)) { $messageLanguageKey = $defaultLanguageKey; } @@ -128,14 +112,11 @@ public function onContentAfterSave($context, $article, $isNew) $id = empty($params->id_holder) ? 0 : $article->get($params->id_holder); $message = array( - 'action' => $action, - 'type' => strtoupper($params->text_prefix . '_TYPE_' . $contentTypeTitle), - 'id' => $id, - 'title' => $article->get($params->title_holder), - 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $id), - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'action' => $isNew ? 'add' : 'update', + 'type' => $params->text_prefix . '_TYPE_' . $params->type_title, + 'id' => $id, + 'title' => $article->get($params->title_holder), + 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $id) ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -170,30 +151,23 @@ public function onContentAfterDelete($context, $article) return; } - $language = JFactory::getLanguage(); - $user = JFactory::getUser(); - $contentTypeTitle = strtoupper($params->type_title); - // If the content type has it own language key, use it, otherwise, use default language key - if ($language->hasKey(strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_DELETED'))) + if ($this->app->getLanguage()->hasKey(strtoupper($params->text_prefix . '_' . $params->type_title . '_DELETED'))) { - $messageLanguageKey = strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_DELETED'); + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_DELETED'; } else { - $messageLanguageKey = strtoupper('PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'); + $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; } $id = empty($params->id_holder) ? 0 : $article->get($params->id_holder); $message = array( - 'action' => 'delete', - 'type' => strtoupper($params->text_prefix . '_TYPE_' . $contentTypeTitle), - 'id' => $id, - 'title' => $article->get($params->title_holder), - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'action' => 'delete', + 'type' => $params->text_prefix . '_TYPE_' . $params->type_title, + 'id' => $id, + 'title' => $article->get($params->title_holder) ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -229,29 +203,27 @@ public function onContentChangeState($context, $pks, $value) return; } - $user = JFactory::getUser(); - $contentTypeTitle = strtoupper($params->type_title); list(, $contentType) = explode('.', $params->type_alias); switch ($value) { case 0: - $messageLanguageKey = strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_UNPUBLISHED'); + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_UNPUBLISHED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UNPUBLISHED'; $action = 'unpublish'; break; case 1: - $messageLanguageKey = strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_PUBLISHED'); + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_PUBLISHED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_PUBLISHED'; $action = 'publish'; break; case 2: - $messageLanguageKey = strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_ARCHIVED'); + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_ARCHIVED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ARCHIVED'; $action = 'archive'; break; case -2: - $messageLanguageKey = strtoupper($params->text_prefix . '_' . $contentTypeTitle . '_TRASHED'); + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_TRASHED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_TRASHED'; $action = 'trash'; break; @@ -263,12 +235,12 @@ public function onContentChangeState($context, $pks, $value) } // If the content type doesn't has it own language key, use default language key - if (!JFactory::getLanguage()->hasKey($messageLanguageKey)) + if (!$this->app->getLanguage()->hasKey($messageLanguageKey)) { $messageLanguageKey = $defaultLanguageKey; } - $db = JFactory::getDbo(); + $db = $this->db; $query = $db->getQuery(true) ->select($db->quoteName(array($params->title_holder, $params->id_holder))) ->from($db->quoteName($params->table_name)) @@ -290,13 +262,10 @@ public function onContentChangeState($context, $pks, $value) { $message = array( 'action' => $action, - 'type' => strtoupper($params->text_prefix . '_TYPE_' . $params->type_title), + 'type' => $params->text_prefix . '_TYPE_' . $params->type_title, 'id' => $pk, 'title' => $items[$pk]->{$params->title_holder}, - 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $pk), - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $pk) ); $messages[] = $message; @@ -324,19 +293,14 @@ public function onApplicationAfterSave($config) return; } - $messageLanguageKey = strtoupper('PLG_ACTIONLOG_JOOMLA_APPLICATION_CONFIG_UPDATED'); + $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_APPLICATION_CONFIG_UPDATED'; $action = 'update'; - $user = JFactory::getUser(); - $message = array( 'action' => $action, - 'type' => strtoupper('PLG_ACTIONLOG_JOOMLA_TYPE_APPLICATION_CONFIG'), + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_APPLICATION_CONFIG', 'extension_name' => 'com_config.application', - 'itemlink' => 'index.php?option=com_config', - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'itemlink' => 'index.php?option=com_config' ); $this->addLog(array($message), $messageLanguageKey, 'com_config.application'); @@ -363,8 +327,6 @@ public function onExtensionAfterInstall($installer, $eid) return; } - $language = JFactory::getLanguage(); - $user = JFactory::getUser(); $manifest = $installer->get('manifest'); if ($manifest === null) @@ -375,9 +337,9 @@ public function onExtensionAfterInstall($installer, $eid) $extensionType = $manifest->attributes()->type; // If the extension type has it own language key, use it, otherwise, use default language key - if ($language->hasKey(strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_INSTALLED'))) + if ($this->app->getLanguage()->hasKey(strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_INSTALLED'))) { - $messageLanguageKey = strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_INSTALLED'); + $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_INSTALLED'; } else { @@ -386,13 +348,10 @@ public function onExtensionAfterInstall($installer, $eid) $message = array( 'action' => 'install', - 'type' => strtoupper('PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType), + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType, 'id' => $eid, 'name' => (string) $manifest->name, - 'extension_name' => (string) $manifest->name, - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'extension_name' => (string) $manifest->name ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -426,8 +385,6 @@ public function onExtensionAfterUninstall($installer, $eid, $result) return; } - $language = JFactory::getLanguage(); - $user = JFactory::getUser(); $manifest = $installer->get('manifest'); if ($manifest === null) @@ -438,9 +395,9 @@ public function onExtensionAfterUninstall($installer, $eid, $result) $extensionType = $manifest->attributes()->type; // If the extension type has it own language key, use it, otherwise, use default language key - if ($language->hasKey(strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UNINSTALLED'))) + if ($this->app->getLanguage()->hasKey(strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UNINSTALLED'))) { - $messageLanguageKey = strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UNINSTALLED'); + $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UNINSTALLED'; } else { @@ -449,13 +406,10 @@ public function onExtensionAfterUninstall($installer, $eid, $result) $message = array( 'action' => 'install', - 'type' => strtoupper('PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType), + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType, 'id' => $eid, 'name' => (string) $manifest->name, - 'extension_name' => (string) $manifest->name, - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'extension_name' => (string) $manifest->name ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -482,8 +436,6 @@ public function onExtensionAfterUpdate($installer, $eid) return; } - $language = JFactory::getLanguage(); - $user = JFactory::getUser(); $manifest = $installer->get('manifest'); if ($manifest === null) @@ -494,9 +446,9 @@ public function onExtensionAfterUpdate($installer, $eid) $extensionType = $manifest->attributes()->type; // If the extension type has it own language key, use it, otherwise, use default language key - if ($language->hasKey(strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UPDATED'))) + if ($this->app->getLanguage()->hasKey('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UPDATED')) { - $messageLanguageKey = strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UPDATED'); + $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UPDATED'; } else { @@ -505,13 +457,10 @@ public function onExtensionAfterUpdate($installer, $eid) $message = array( 'action' => 'update', - 'type' => strtoupper('PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType), + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType, 'id' => $eid, 'name' => (string) $manifest->name, - 'extension_name' => (string) $manifest->name, - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'extension_name' => (string) $manifest->name ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -533,6 +482,11 @@ public function onExtensionAfterSave($context, $table, $isNew) { $option = $this->app->input->getCmd('option'); + if ($table->get('module') != null) + { + $option = 'com_modules'; + } + if (!$this->checkLoggable($option)) { return; @@ -546,40 +500,32 @@ public function onExtensionAfterSave($context, $table, $isNew) return; } - $extensionType = $params->type_title; list(, $contentType) = explode('.', $params->type_alias); if ($isNew) { - $messageLanguageKey = strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_ADDED'); - $defaultLanguageKey = strtoupper('PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'); - $action = 'add'; + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_ADDED'; + $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'; } else { - $messageLanguageKey = strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UPDATED'); + $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_UPDATED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED'; - $action = 'update'; } // If the extension type doesn't have it own language key, use default language key - if (!JFactory::getLanguage()->hasKey($messageLanguageKey)) + if (!$this->app->getLanguage()->hasKey($messageLanguageKey)) { $messageLanguageKey = $defaultLanguageKey; } - $user = JFactory::getUser(); - $message = array( - 'action' => $action, - 'type' => strtoupper('PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType), + 'action' => $isNew ? 'add' : 'update', + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $params->type_title, 'id' => $table->get($params->id_holder), 'title' => $table->get($params->title_holder), 'extension_name' => $table->get($params->title_holder), - 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $table->get($params->id_holder), $params->id_holder), - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $table->get($params->id_holder), $params->id_holder) ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -611,16 +557,12 @@ public function onExtensionAfterDelete($context, $table) return; } - $messageLanguageKey = strtoupper('PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'); - $user = JFactory::getUser(); + $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; $message = array( - 'action' => 'delete', - 'type' => strtoupper('PLG_ACTIONLOG_JOOMLA_TYPE_' . $params->type_title), - 'title' => $table->get($params->title_holder), - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'action' => 'delete', + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $params->type_title, + 'title' => $table->get($params->title_holder) ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -683,7 +625,7 @@ public function onUserAfterSave($user, $isnew, $success, $msg) $action = 'update'; } - $userId = $jUser->id ?: $user['id']; + $userId = $jUser->id ?: $user['id']; $username = $jUser->username ?: $user['username']; $message = array( @@ -723,16 +665,12 @@ public function onUserAfterDelete($user, $success, $msg) } $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; - $jUser = JFactory::getUser(); $message = array( 'action' => 'delete', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user['id'], - 'title' => $user['name'], - 'userid' => $jUser->id, - 'username' => $jUser->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $jUser->id, + 'title' => $user['name'] ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -771,17 +709,12 @@ public function onUserAfterSaveGroup($context, $table, $isNew) $action = 'update'; } - $user = JFactory::getUser(); - $message = array( 'action' => $action, 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER_GROUP', 'id' => $table->id, 'title' => $table->title, - 'itemlink' => 'index.php?option=com_users&task=group.edit&id=' . $table->id, - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'itemlink' => 'index.php?option=com_users&task=group.edit&id=' . $table->id ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -809,18 +742,13 @@ public function onUserAfterDeleteGroup($group, $success, $msg) return; } - $user = JFactory::getUser(); - $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; $message = array( 'action' => 'delete', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER_GROUP', 'id' => $group['id'], - 'title' => $group['title'], - 'userid' => $user->id, - 'username' => $user->username, - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'title' => $group['title'] ); $this->addLog(array($message), $messageLanguageKey, $context); @@ -849,9 +777,10 @@ public function onUserAfterLogin($options) $message = array( 'action' => 'login', + 'userid' => $loggedInUser->id, 'username' => $loggedInUser->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $loggedInUser->id, - 'app' => strtoupper('PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName()), + 'app' => 'PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName(), ); $this->addLog(array($message), $messageLanguageKey, $context, $loggedInUser->id); @@ -875,7 +804,7 @@ public function onUserLoginFailure($response) return; } - $loggedInUser = JUser::getInstance($response['username']); + $loggedInUser = JUser::getInstance($response['username']); // Not a valid user, return if (!$loggedInUser->id) @@ -888,9 +817,10 @@ public function onUserLoginFailure($response) $message = array( 'action' => 'login', 'id' => $loggedInUser->id, + 'userid' => $loggedInUser->id, 'username' => $loggedInUser->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $loggedInUser->id, - 'app' => strtoupper('PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName()), + 'app' => 'PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName(), ); $this->addLog(array($message), $messageLanguageKey, $context, $loggedInUser->id); @@ -921,37 +851,15 @@ public function onUserLogout($user, $options = array()) $message = array( 'action' => 'logout', 'id' => $loggedOutUser->id, + 'userid' => $loggedOutUser->id, 'username' => $loggedOutUser->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $loggedOutUser->id, - 'app' => strtoupper('PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName()), + 'app' => 'PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName(), ); $this->addLog(array($message), $messageLanguageKey, $context); } - /** - * Proxy for ActionlogsModelUserlog addLog method - * - * This method adds a record to #__action_logs contains (message_language_key, message, date, context, user) - * - * @param array $messages The contents of the messages to be logged - * @param string $messageLanguageKey The language key of the message - * @param string $context The context of the content passed to the plugin - * @param int $userId ID of user perform the action, usually ID of current logged in user - * - * @return void - * - * @since 3.9.0 - */ - protected function addLog($messages, $messageLanguageKey, $context, $userId = null) - { - JLoader::register('ActionlogsModelActionlog', JPATH_ADMINISTRATOR . '/components/com_actionlogs/models/actionlog.php'); - - /* @var ActionlogsModelActionlog $model */ - $model = JModelLegacy::getInstance('Actionlog', 'ActionlogsModel'); - $model->addLog($messages, $messageLanguageKey, $context, $userId); - } - /** * Function to check if a component is loggable or not * diff --git a/plugins/privacy/actionlogs/actionlogs.php b/plugins/privacy/actionlogs/actionlogs.php index c79f7a6b920ee..94499b16792dd 100644 --- a/plugins/privacy/actionlogs/actionlogs.php +++ b/plugins/privacy/actionlogs/actionlogs.php @@ -20,22 +20,6 @@ */ class PlgPrivacyActionlogs extends PrivacyPlugin { - /** - * Database object - * - * @var JDatabaseDriver - * @since 3.9.0 - */ - protected $db; - - /** - * Affects constructor behavior. If true, language files will be loaded automatically. - * - * @var boolean - * @since 3.9.0 - */ - protected $autoloadLanguage = true; - /** * Processes an export request for Joomla core actionlog data * diff --git a/plugins/privacy/contact/contact.php b/plugins/privacy/contact/contact.php index cce6eefbd3eef..01d6897a78936 100644 --- a/plugins/privacy/contact/contact.php +++ b/plugins/privacy/contact/contact.php @@ -9,7 +9,6 @@ defined('_JEXEC') or die; -JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); JLoader::register('PrivacyTableRequest', JPATH_ADMINISTRATOR . '/components/com_privacy/tables/request.php'); @@ -20,30 +19,6 @@ */ class PlgPrivacyContact extends PrivacyPlugin { - /** - * Database object - * - * @var JDatabaseDriver - * @since 3.9.0 - */ - protected $db; - - /** - * Affects constructor behaviour. If true, language files will be loaded automatically. - * - * @var boolean - * @since 3.9.0 - */ - protected $autoloadLanguage = true; - - /** - * Contacts array - * - * @var array - * @since 3.9.0 - */ - protected $contacts = array(); - /** * Processes an export request for Joomla core user contact data * @@ -60,95 +35,37 @@ class PlgPrivacyContact extends PrivacyPlugin */ public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user = null) { - if ((!$user) && (!$request->email)) + if (!$user && !$request->email) { return array(); } $domains = array(); - $domains[] = $this->createContactDomain($request, $user); - - // An user may have more than 1 contact linked to them - foreach ($this->contacts as $contact) - { - $domains[] = $this->createContactCustomFieldsDomain($contact); - } + $domain = $this->createDomain('user_contact', 'joomla_user_contact_data'); + $domains[] = $domain; - return $domains; - } - - /** - * Create the domain for the user contact data - * - * @param PrivacyTableRequest $request The request record being processed - * @param JUser $user The user account associated with this request if available - * - * @return PrivacyExportDomain - * - * @since 3.9.0 - */ - private function createContactDomain(PrivacyTableRequest $request, JUser $user = null) - { - $domain = $this->createDomain('user_contact', 'joomla_user_contact_data'); + $query = $this->db->getQuery(true) + ->select('*') + ->from($this->db->quoteName('#__contact_details')) + ->order($this->db->quoteName('ordering') . ' ASC'); if ($user) { - $query = $this->db->getQuery(true) - ->select('*') - ->from($this->db->quoteName('#__contact_details')) - ->where($this->db->quoteName('user_id') . ' = ' . (int) $user->id) - ->order($this->db->quoteName('ordering') . ' ASC'); + $query->where($this->db->quoteName('user_id') . ' = ' . (int) $user->id); } else { - $query = $this->db->getQuery(true) - ->select('*') - ->from($this->db->quoteName('#__contact_details')) - ->where($this->db->quoteName('email_to') . ' = ' . $this->db->quote($request->email)) - ->order($this->db->quoteName('ordering') . ' ASC'); + $query->where($this->db->quoteName('email_to') . ' = ' . $this->db->quote($request->email)); } - $items = $this->db->setQuery($query)->loadAssocList(); + $items = $this->db->setQuery($query)->loadObjectList(); foreach ($items as $item) { - $domain->addItem($this->createItemFromArray($item)); - $this->contacts[] = (object) $item; - } - - return $domain; - } - - /** - * Create the domain for the contact custom fields - * - * @param Object $contact The contact to process - * - * @return PrivacyExportDomain - * - * @since 3.9.0 - */ - private function createContactCustomFieldsDomain($contact) - { - $domain = $this->createDomain('contact_custom_fields', 'joomla_contact_custom_fields_data'); - - // Get item's fields, also preparing their value property for manual display - $fields = FieldsHelper::getFields('com_contact.contact', $contact); - - foreach ($fields as $field) - { - $fieldValue = is_array($field->value) ? implode(', ', $field->value) : $field->value; - - $data = array( - 'contact_id' => $contact->id, - 'field_name' => $field->name, - 'field_title' => $field->title, - 'field_value' => $fieldValue, - ); - - $domain->addItem($this->createItemFromArray($data)); + $domain->addItem($this->createItemFromArray((array) $item)); + $domains[] = $this->createCustomFieldsDomain('com_contact.contact', $item); } - return $domain; + return $domains; } } diff --git a/plugins/privacy/content/content.php b/plugins/privacy/content/content.php index b70ed8dff055e..3ec0d56ba507d 100644 --- a/plugins/privacy/content/content.php +++ b/plugins/privacy/content/content.php @@ -9,7 +9,6 @@ defined('_JEXEC') or die; -JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); JLoader::register('PrivacyTableRequest', JPATH_ADMINISTRATOR . '/components/com_privacy/tables/request.php'); @@ -20,30 +19,6 @@ */ class PlgPrivacyContent extends PrivacyPlugin { - /** - * Database object - * - * @var JDatabaseDriver - * @since 3.9.0 - */ - protected $db; - - /** - * Affects constructor behaviour. If true, language files will be loaded automatically. - * - * @var boolean - * @since 3.9.0 - */ - protected $autoloadLanguage = true; - - /** - * Contents array - * - * @var array - * @since 3.9.0 - */ - protected $contents = array(); - /** * Processes an export request for Joomla core user content data * @@ -66,28 +41,8 @@ public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user } $domains = array(); - $domains[] = $this->createContentDomain($user); - - foreach ($this->contents as $content) - { - $domains[] = $this->createContentCustomFieldsDomain($content); - } - - return $domains; - } - - /** - * Create the domain for the user content data - * - * @param JUser $user The user account associated with this request - * - * @return PrivacyExportDomain - * - * @since 3.9.0 - */ - private function createContentDomain(JUser $user) - { - $domain = $this->createDomain('user_content', 'joomla_user_content_data'); + $domain = $this->createDomain('user_content', 'joomla_user_content_data'); + $domains[] = $domain; $query = $this->db->getQuery(true) ->select('*') @@ -95,47 +50,14 @@ private function createContentDomain(JUser $user) ->where($this->db->quoteName('created_by') . ' = ' . (int) $user->id) ->order($this->db->quoteName('ordering') . ' ASC'); - $items = $this->db->setQuery($query)->loadAssocList(); + $items = $this->db->setQuery($query)->loadObjectList(); foreach ($items as $item) { - $domain->addItem($this->createItemFromArray($item)); - $this->contents[] = (object) $item; + $domain->addItem($this->createItemFromArray((array) $item)); + $domains[] = $this->createCustomFieldsDomain('com_content.article', $item); } - return $domain; - } - - /** - * Create the domain for the content custom fields - * - * @param Object $content The content to process - * - * @return PrivacyExportDomain - * - * @since 3.9.0 - */ - private function createContentCustomFieldsDomain($content) - { - $domain = $this->createDomain('content_custom_fields', 'joomla_content_custom_fields_data'); - - // Get item's fields, also preparing their value property for manual display - $fields = FieldsHelper::getFields('com_content.article', $content); - - foreach ($fields as $field) - { - $fieldValue = is_array($field->value) ? implode(', ', $field->value) : $field->value; - - $data = array( - 'content_id' => $content->id, - 'field_name' => $field->name, - 'field_title' => $field->title, - 'field_value' => $fieldValue, - ); - - $domain->addItem($this->createItemFromArray($data)); - } - - return $domain; + return $domains; } } diff --git a/plugins/privacy/message/message.php b/plugins/privacy/message/message.php index 590bc9d3d91a7..cdcd5d2f258b3 100644 --- a/plugins/privacy/message/message.php +++ b/plugins/privacy/message/message.php @@ -19,22 +19,6 @@ */ class PlgPrivacyMessage extends PrivacyPlugin { - /** - * Database object - * - * @var JDatabaseDriver - * @since 3.9.0 - */ - protected $db; - - /** - * Affects constructor behaviour. If true, language files will be loaded automatically. - * - * @var boolean - * @since 3.9.0 - */ - protected $autoloadLanguage = true; - /** * Processes an export request for Joomla core user message * @@ -54,23 +38,6 @@ public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user return array(); } - $domains = array(); - $domains[] = $this->createMessageDomain($user); - - return $domains; - } - - /** - * Create the domain for the user message data - * - * @param JUser $user The user account associated with this request - * - * @return PrivacyExportDomain - * - * @since 3.9.0 - */ - private function createMessageDomain(JUser $user) - { $domain = $this->createDomain('user_messages', 'joomla_user_messages_data'); $query = $this->db->getQuery(true) @@ -87,6 +54,6 @@ private function createMessageDomain(JUser $user) $domain->addItem($this->createItemFromArray($item)); } - return $domain; + return array($domain); } } diff --git a/plugins/privacy/user/user.php b/plugins/privacy/user/user.php index 7b05e9dfa89ad..7561fac31e5a1 100644 --- a/plugins/privacy/user/user.php +++ b/plugins/privacy/user/user.php @@ -11,7 +11,6 @@ use Joomla\Utilities\ArrayHelper; -JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); 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'); @@ -23,22 +22,6 @@ */ class PlgPrivacyUser extends PrivacyPlugin { - /** - * Database object - * - * @var JDatabaseDriver - * @since 3.9.0 - */ - protected $db; - - /** - * Affects constructor behavior. If true, language files will be loaded automatically. - * - * @var boolean - * @since 3.9.0 - */ - protected $autoloadLanguage = true; - /** * Performs validation to determine if the data associated with a remove information request can be processed * @@ -101,7 +84,7 @@ public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user $domains[] = $this->createUserDomain($userTable); $domains[] = $this->createNotesDomain($userTable); $domains[] = $this->createProfileDomain($userTable); - $domains[] = $this->createUserCustomFieldsDomain($userTable); + $domains[] = $this->createCustomFieldsDomain('com_users.user', $userTable); return $domains; } @@ -273,37 +256,4 @@ private function createItemForUserTable(JTableUser $user) return $this->createItemFromArray($data, $user->id); } - - /** - * Create the domain for the user custom fields - * - * @param JTableUser $user The JTableUser object to process - * - * @return PrivacyExportDomain - * - * @since 3.9.0 - */ - private function createUserCustomFieldsDomain(JTableUser $user) - { - $domain = $this->createDomain('user_custom_fields', 'joomla_user_custom_fields_data'); - - // Get item's fields, also preparing their value property for manual display - $fields = FieldsHelper::getFields('com_users.user', $user); - - foreach ($fields as $field) - { - $fieldValue = is_array($field->value) ? implode(', ', $field->value) : $field->value; - - $data = array( - 'user_id' => $user->id, - 'field_name' => $field->name, - 'field_title' => $field->title, - 'field_value' => $fieldValue, - ); - - $domain->addItem($this->createItemFromArray($data)); - } - - return $domain; - } } diff --git a/plugins/quickicon/privacycheck/privacycheck.php b/plugins/quickicon/privacycheck/privacycheck.php index cb2cec3c7411b..d50f68455118a 100644 --- a/plugins/quickicon/privacycheck/privacycheck.php +++ b/plugins/quickicon/privacycheck/privacycheck.php @@ -54,11 +54,11 @@ public function onGetIcons($context) 'plg_quickicon_privacycheck_url' => Uri::base() . $privacy . '&view=requests&filter[status]=1&list[fullordering]=a.requested_at ASC', 'plg_quickicon_privacycheck_ajax_url' => Uri::base() . $privacy . '&task=getNumberUrgentRequests&' . $token, 'plg_quickicon_privacycheck_text' => array( - "NOREQUEST" => Text::_('PLG_QUICKICON_PRIVACYCHECK_NOREQUEST', true), - "REQUESTFOUND" => Text::_('PLG_QUICKICON_PRIVACYCHECK_REQUESTFOUND', true), - "REQUESTFOUND_MESSAGE" => Text::_('PLG_QUICKICON_PRIVACYCHECK_REQUESTFOUND_MESSAGE', true), - "REQUESTFOUND_BUTTON" => Text::_('PLG_QUICKICON_PRIVACYCHECK_REQUESTFOUND_BUTTON', true), - "ERROR" => Text::_('PLG_QUICKICON_PRIVACYCHECK_ERROR', true), + "NOREQUEST" => Text::_('PLG_QUICKICON_PRIVACYCHECK_NOREQUEST'), + "REQUESTFOUND" => Text::_('PLG_QUICKICON_PRIVACYCHECK_REQUESTFOUND'), + "REQUESTFOUND_MESSAGE" => Text::_('PLG_QUICKICON_PRIVACYCHECK_REQUESTFOUND_MESSAGE'), + "REQUESTFOUND_BUTTON" => Text::_('PLG_QUICKICON_PRIVACYCHECK_REQUESTFOUND_BUTTON'), + "ERROR" => Text::_('PLG_QUICKICON_PRIVACYCHECK_ERROR'), ) );