diff --git a/administrator/components/com_actionlogs/config.xml b/administrator/components/com_actionlogs/config.xml index c8450079348..ce40015c598 100644 --- a/administrator/components/com_actionlogs/config.xml +++ b/administrator/components/com_actionlogs/config.xml @@ -29,7 +29,7 @@ label="COM_ACTIONLOGS_LOG_EXTENSIONS_LABEL" description="COM_ACTIONLOGS_LOG_EXTENSIONS_DESC" multiple="true" - default="com_banners,com_cache,com_categories,com_config,com_contact,com_content,com_installer,com_media,com_menus,com_messages,com_modules,com_newsfeeds,com_plugins,com_redirect,com_tags,com_templates,com_users" + default="com_banners,com_cache,com_categories,com_checkin,com_config,com_contact,com_content,com_installer,com_media,com_menus,com_messages,com_modules,com_newsfeeds,com_plugins,com_redirect,com_tags,com_templates,com_users" /> diff --git a/administrator/components/com_admin/sql/updates/mysql/3.9.3-2019-01-12.sql b/administrator/components/com_admin/sql/updates/mysql/3.9.3-2019-01-12.sql new file mode 100644 index 00000000000..f5d2d6ca9c0 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/3.9.3-2019-01-12.sql @@ -0,0 +1,6 @@ +UPDATE `#__extensions` +SET `params` = REPLACE(`params`, '"com_categories",', '"com_categories","com_checkin",') +WHERE `name` = 'com_actionlogs'; + +INSERT INTO `#__action_logs_extensions` (`extension`) VALUES +('com_checkin'); \ No newline at end of file diff --git a/administrator/components/com_admin/sql/updates/postgresql/3.9.3-2019-01-12.sql b/administrator/components/com_admin/sql/updates/postgresql/3.9.3-2019-01-12.sql new file mode 100644 index 00000000000..c31ae5d9117 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/3.9.3-2019-01-12.sql @@ -0,0 +1,8 @@ +UPDATE "#__extensions" +SET "params" = REPLACE("params", '"com_categories",', '"com_categories","com_checkin",') +WHERE "name" = 'com_actionlogs'; + +INSERT INTO "#__action_logs_extensions" ("extension") VALUES +('com_checkin'); + +SELECT setval('#__action_logs_extensions_id_seq', max(id)) FROM "#__action_logs_extensions"; \ No newline at end of file diff --git a/administrator/components/com_admin/sql/updates/sqlazure/3.9.3-2019-01-12.sql b/administrator/components/com_admin/sql/updates/sqlazure/3.9.3-2019-01-12.sql new file mode 100644 index 00000000000..6f02ce0c8fb --- /dev/null +++ b/administrator/components/com_admin/sql/updates/sqlazure/3.9.3-2019-01-12.sql @@ -0,0 +1,10 @@ +UPDATE "#__extensions" +SET "params" = REPLACE("params", '"com_categories",', '"com_categories","com_checkin",') +WHERE "name" = 'com_actionlogs'; + +SET IDENTITY_INSERT #__extensions ON; + +INSERT INTO "#__action_logs_extensions" ("extension") VALUES +('com_checkin'); + +SET IDENTITY_INSERT #__extensions OFF; \ No newline at end of file diff --git a/administrator/components/com_checkin/models/checkin.php b/administrator/components/com_checkin/models/checkin.php index d8fdcd1bfb2..413ed839b00 100644 --- a/administrator/components/com_checkin/models/checkin.php +++ b/administrator/components/com_checkin/models/checkin.php @@ -94,6 +94,8 @@ class CheckinModelCheckin extends JModelList // This int will hold the checked item count. $results = 0; + $dispatcher = \JEventDispatcher::getInstance(); + foreach ($ids as $tn) { // Make sure we get the right tables based on prefix. @@ -111,15 +113,16 @@ class CheckinModelCheckin extends JModelList $query = $db->getQuery(true) ->update($db->quoteName($tn)) - ->set('checked_out = DEFAULT') - ->set('checked_out_time = ' . $db->quote($nullDate)) - ->where('checked_out > 0'); + ->set($db->quoteName('checked_out') . ' = DEFAULT') + ->set($db->quoteName('checked_out_time') . ' = ' . $db->quote($nullDate)) + ->where($db->quoteName('checked_out') . ' > 0'); $db->setQuery($query); if ($db->execute()) { $results = $results + $db->getAffectedRows(); + $dispatcher->trigger('onAfterCheckin', array($tn)); } } diff --git a/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini b/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini index 22a038272cd..f61590b1453 100644 --- a/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini +++ b/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini @@ -35,6 +35,7 @@ PLG_ACTIONLOG_JOOMLA_TYPE_TEMPLATE="template" PLG_ACTIONLOG_JOOMLA_TYPE_USER="user" PLG_ACTIONLOG_JOOMLA_TYPE_USER_GROUP="user group" PLG_ACTIONLOG_JOOMLA_TYPE_USER_NOTE="user note" +PLG_ACTIONLOG_JOOMLA_USER_CHECKIN="User {username} performed a check in to table {table}" PLG_ACTIONLOG_JOOMLA_USER_LOGGED_IN="User {username} logged in to {app}" PLG_ACTIONLOG_JOOMLA_USER_LOGGED_OUT="User {username} logged out from {app}" PLG_ACTIONLOG_JOOMLA_USER_LOGIN_FAILED="User {username} tried to login to {app}" diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index a7a087dcdfc..e1576fd2a68 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -526,7 +526,7 @@ INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `elem (33, 0, 'com_fields', 'component', 'com_fields', '', 1, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (34, 0, 'com_associations', 'component', 'com_associations', '', 1, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (35, 0, 'com_privacy', 'component', 'com_privacy', '', 1, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), -(36, 0, 'com_actionlogs', 'component', 'com_actionlogs', '', 1, 1, 1, 1, '', '{"ip_logging":0,"csv_delimiter":",","loggable_extensions":["com_banners","com_cache","com_categories","com_config","com_contact","com_content","com_installer","com_media","com_menus","com_messages","com_modules","com_newsfeeds","com_plugins","com_redirect","com_tags","com_templates","com_users"]}', '', '', 0, '0000-00-00 00:00:00', 0, 0), +(36, 0, 'com_actionlogs', 'component', 'com_actionlogs', '', 1, 1, 1, 1, '', '{"ip_logging":0,"csv_delimiter":",","loggable_extensions":["com_banners","com_cache","com_categories","com_checkin","com_config","com_contact","com_content","com_installer","com_media","com_menus","com_messages","com_modules","com_newsfeeds","com_plugins","com_redirect","com_tags","com_templates","com_users"]}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (102, 0, 'phputf8', 'library', 'phputf8', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (103, 0, 'Joomla! Platform', 'library', 'joomla', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (104, 0, 'IDNA Convert', 'library', 'idna_convert', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), @@ -2195,7 +2195,8 @@ INSERT INTO `#__action_logs_extensions` (`id`, `extension`) VALUES (14, 'com_redirect'), (15, 'com_tags'), (16, 'com_templates'), -(17, 'com_users'); +(17, 'com_users'), +(18, 'com_checkin'); -- -- Table structure for table `#__action_log_config` diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index ff3251aefb3..2180f37f0d0 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -539,7 +539,7 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem (33, 0, 'com_fields', 'component', 'com_fields', '', 1, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (34, 0, 'com_associations', 'component', 'com_associations', '', 1, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (35, 0, 'com_privacy', 'component', 'com_privacy', '', 1, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), -(36, 0, 'com_actionlogs', 'component', 'com_actionlogs', '', 1, 1, 1, 1, '', '{"ip_logging":0,"csv_delimiter":",","loggable_extensions":["com_banners","com_cache","com_categories","com_config","com_contact","com_content","com_installer","com_media","com_menus","com_messages","com_modules","com_newsfeeds","com_plugins","com_redirect","com_tags","com_templates","com_users"]}', '', '', 0, '1970-01-01 00:00:00', 0, 0), +(36, 0, 'com_actionlogs', 'component', 'com_actionlogs', '', 1, 1, 1, 1, '', '{"ip_logging":0,"csv_delimiter":",","loggable_extensions":["com_banners","com_cache","com_categories","com_checkin","com_config","com_contact","com_content","com_installer","com_media","com_menus","com_messages","com_modules","com_newsfeeds","com_plugins","com_redirect","com_tags","com_templates","com_users"]}', '', '', 0, '1970-01-01 00:00:00', 0, 0), (102, 0, 'phputf8', 'library', 'phputf8', '', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (103, 0, 'Joomla! Platform', 'library', 'joomla', '', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (104, 0, 'IDNA Convert', 'library', 'idna_convert', '', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), @@ -2176,9 +2176,10 @@ INSERT INTO "#__action_logs_extensions" ("id", "extension") VALUES (14, 'com_redirect'), (15, 'com_tags'), (16, 'com_templates'), -(17, 'com_users'); +(17, 'com_users'), +(18, 'com_checkin'); -SELECT setval('#__action_logs_extensions_id_seq', 18, false); +SELECT setval('#__action_logs_extensions_id_seq', 19, false); -- -------------------------------------------------------- -- diff --git a/installation/sql/sqlazure/joomla.sql b/installation/sql/sqlazure/joomla.sql index c0d9c23716e..f6af5d8f092 100644 --- a/installation/sql/sqlazure/joomla.sql +++ b/installation/sql/sqlazure/joomla.sql @@ -754,7 +754,7 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem (33, 0, 'com_fields', 'component', 'com_fields', '', 1, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), (34, 0, 'com_associations', 'component', 'com_associations', '', 1, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), (35, 0, 'com_privacy', 'component', 'com_privacy', '', 1, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), -(36, 0, 'com_actionlogs', 'component', 'com_actionlogs', '', 1, 1, 1, 1, '', '{"ip_logging":0,"csv_delimiter":",","loggable_extensions":["com_banners","com_cache","com_categories","com_config","com_contact","com_content","com_installer","com_media","com_menus","com_messages","com_modules","com_newsfeeds","com_plugins","com_redirect","com_tags","com_templates","com_users"]}', '', '', 0, '1900-01-01 00:00:00', 0, 0), +(36, 0, 'com_actionlogs', 'component', 'com_actionlogs', '', 1, 1, 1, 1, '', '{"ip_logging":0,"csv_delimiter":",","loggable_extensions":["com_banners","com_cache","com_categories","com_checkin","com_config","com_contact","com_content","com_installer","com_media","com_menus","com_messages","com_modules","com_newsfeeds","com_plugins","com_redirect","com_tags","com_templates","com_users"]}', '', '', 0, '1900-01-01 00:00:00', 0, 0), (102, 0, 'phputf8', 'library', 'phputf8', '', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), (103, 0, 'Joomla! Platform', 'library', 'joomla', '', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), (104, 0, 'IDNA Convert', 'library', 'idna_convert', '', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0), @@ -3139,7 +3139,9 @@ SELECT 15, 'com_tags' UNION ALL SELECT 16, 'com_templates' UNION ALL -SELECT 17, 'com_users'; +SELECT 17, 'com_users' +UNION ALL +SELECT 18, 'com_checkin'; SET IDENTITY_INSERT [#__action_logs_extensions] OFF; /****** Object: Table [#__action_log_config] ******/ diff --git a/libraries/src/Table/Table.php b/libraries/src/Table/Table.php index a699b833623..3eed88e1598 100644 --- a/libraries/src/Table/Table.php +++ b/libraries/src/Table/Table.php @@ -1145,6 +1145,9 @@ abstract class Table extends \JObject implements \JObservableInterface, \JTableI $this->$checkedOutField = 0; $this->$checkedOutTimeField = ''; + $dispatcher = \JEventDispatcher::getInstance(); + $dispatcher->trigger('onAfterCheckin', array($this->_tbl)); + return true; } diff --git a/plugins/actionlog/joomla/joomla.php b/plugins/actionlog/joomla/joomla.php index 0b308d14e87..be959b670f2 100644 --- a/plugins/actionlog/joomla/joomla.php +++ b/plugins/actionlog/joomla/joomla.php @@ -909,4 +909,40 @@ class PlgActionlogJoomla extends ActionLogPlugin $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_REMIND', $context, $user->id); } + + /** + * On after Check-in request + * + * Method is called after user request to check-in items. + * + * @param array $table Holds the table name. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function onAfterCheckin($table) + { + $context = $this->app->input->get('option'); + $user = Factory::getUser(); + + if (!$this->checkLoggable($context)) + { + return; + } + + $message = array( + 'action' => 'checkin', + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', + 'id' => $user->id, + 'title' => $user->name, + 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'userid' => $user->id, + 'username' => $user->name, + 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'table' => $table, + ); + + $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_CHECKIN', $context, $user->id); + } }