Trying to avoid crons whenever possible, but based on the answer from @Farahmand, I put a variation of this code in a User Plugin onUserLogout()
event:
When any user logs out, the plugin checks-in any of their content, as well as any other check-outs that may have been abandoned. I wanted only certain user groups to be affected, and to insure that any admin users content was never affected (for our own internal reasons - perhaps overkill for typical installations, but in our case we have custom user groups that can be in several of the standard user groups, so have accounted for that overlap).
function onUserLogout() {
$groups_include = '2,4,10'; // Affect Registered, Publishers, and Custom Group
$groups_exclude = '7,8'; // Don't affect Administrators or Super Users
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update($db->quoteName('#__content'))
->set('checked_out = 0, checked_out_time = 0')
->where('( checked_out = '.JFactory::getUser()->id.' ) OR (
checked_out_time < NOW() - INTERVAL 12 HOUR
AND checked_out IN (SELECT GROUP_CONCAT(user_id) FROM scm_user_usergroup_map WHERE group_id IN ('.$groups_include.'))
AND checked_out NOT IN (SELECT GROUP_CONCAT(user_id) FROM scm_user_usergroup_map WHERE group_id IN ('.$groups_exclude.'))
)'
);
$db->setQuery($query);
$db->execute();
return true;
}
I'm sure the SQL can be adjusted for Timezones, etc., but here's the resulting SQL statement:
UPDATE `gdp_content`
SET checked_out = 0, checked_out_time = 0
WHERE ( checked_out = 30 ) OR (
checked_out_time < NOW() - INTERVAL 12 HOUR
AND checked_out IN (SELECT GROUP_CONCAT(user_id) FROM scm_user_usergroup_map WHERE group_id IN (2,10,11))
AND checked_out NOT IN (SELECT GROUP_CONCAT(user_id) FROM scm_user_usergroup_map WHERE group_id IN (7,8))
)