Skip to content

Commit

Permalink
Add support for User Actions Log (!)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienheraud committed Dec 14, 2018
1 parent 4b31af1 commit 9d0ead6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
6 changes: 0 additions & 6 deletions administrator/components/com_cck/install/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1700,9 +1700,3 @@ CREATE TABLE IF NOT EXISTS `#__cck_store_item_users` (
`company_vat_id` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;


-- --------------------------------------------------------


INSERT IGNORE INTO `#__action_logs_extensions` (`extension`) VALUES ('com_cck');
2 changes: 0 additions & 2 deletions administrator/components/com_cck/install/upgrades/3.17.1.sql

This file was deleted.

26 changes: 26 additions & 0 deletions plugins/content/cck/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ public function postflight( $type, $parent )
$db->setQuery( 'UPDATE #__extensions SET params = "'.$db->escape( $params ).'" WHERE name = "com_cck"' );
$db->execute();


// Set User Actions Log
self::_setUserActionsLog();

// Set Utf8mb4 flag
self::_setUtf8mb4( $params );
} else {
Expand Down Expand Up @@ -629,6 +633,9 @@ public function postflight( $type, $parent )
}
}

// Set User Actions Log
self::_setUserActionsLog();

// Convert Tables To Utf8mb4
self::_convertTablesToUtf8mb4();

Expand Down Expand Up @@ -859,6 +866,25 @@ protected function _forceAutoIncrements()
}
}

// _setUserActionsLog
protected function _setUserActionsLog()
{
$db = JFactory::getDbo();
$db_prefix = JFactory::getConfig()->get( 'dbprefix' );
$table_name = $db_prefix.'action_logs_extensions';
$tables = $db->getTableList();
$tables = array_flip( $tables );

if ( isset( $tables[$table_name] ) ) {
$db->setQuery( 'SELECT COUNT(id) FROM `#__action_logs_extensions` WHERE extension = "com_cck"' );

if ( (int)$db->loadResult() == 0 ) {
$db->setQuery( 'INSERT IGNORE INTO `#__action_logs_extensions` (`extension`) VALUES ("com_cck")' );
$db->execute();
}
}
}

// _setUtf8mb4
protected function _setUtf8mb4( $params )
{
Expand Down

0 comments on commit 9d0ead6

Please sign in to comment.