Ok, the below auto action will delete all expired events. This should also delete their activity since it's doing so from their objects. It takes the end date of the event, or the start date if it doesn't have one, and adds 24 hours to it then checks if the current date is greater than that. If it is then it's considered expired.
Global
Triggers: None
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:
Code:
global $_CB_database;
$query = "SELECT *"
. " FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events' )
. " WHERE ( ( " . $_CB_database->NameQuote( 'end' ) . " = " . $_CB_database->Quote( '0000-00-00 00:00:00' ) . " OR " . $_CB_database->NameQuote( 'end' ) . " IS NULL ) AND DATE_ADD( " . $_CB_database->NameQuote( 'start' ) . ", INTERVAL 24 HOUR ) < NOW() )"
. " OR ( ( " . $_CB_database->NameQuote( 'end' ) . " != " . $_CB_database->Quote( '0000-00-00 00:00:00' ) . " AND " . $_CB_database->NameQuote( 'end' ) . " IS NOT NULL ) AND DATE_ADD( " . $_CB_database->NameQuote( 'end' ) . ", INTERVAL 24 HOUR ) < NOW() )";
$_CB_database->setQuery( $query );
foreach ( $_CB_database->loadObjectList( null, '\CB\Plugin\GroupJiveEvents\Table\EventTable', [ $_CB_database ] ) as $event ) {
$event->delete();
}
Now comes the part of how you want to run this. You can use a Joomla scheduled task to run it on regular intervals as CB Auto Actions includes a scheduled task for running auto actions or you can setup CRON to access the auto action directly. If you plan to use a Joomla scheduled task then please be sure to set "Allow Direct Access" to "No" under the Global tab otherwise leave it as "Yes" and schedule a wget CRON against the "Internal Action URL".
Also since this is a mass delete operation please be sure you make a backup and test carefully.