public function isRequired()
{
$groups = elgg_get_entities_from_metadata(['types' => 'group', 'metadata_names' => 'icontime']);
if (empty($groups)) {
return false;
}
$group = array_pop($groups);
$sizes = elgg_get_icon_sizes('group', $group->getSubtype());
$dataroot = elgg_get_config('dataroot');
$dir = (new \Elgg\EntityDirLocator($group->owner_guid))->getPath();
$prefix = 'groups/';
// Check whether there are icons that are still saved under the
// group's owner instead of the group itself.
foreach ($sizes as $size => $opts) {
$filename = "{$group->guid}{$size}.jpg";
$filestorename = "{$dataroot}{$dir}{$prefix}{$filename}";
if (file_exists($filestorename)) {
// A group icon was found meaning that the upgrade is needed.
return true;
}
}
return false;
}