function find($status = 'active')
{
$db_prefix = elgg_get_config('dbprefix');
$priority = $this->namespacePrivateSetting('internal', 'priority');
$site_guid = elgg_get_site_entity()->guid;
// grab plugins
$options = array('type' => 'object', 'subtype' => 'plugin', 'limit' => ELGG_ENTITIES_NO_VALUE, 'selects' => array('plugin_oe.*', 'ps.value'), 'joins' => array("JOIN {$db_prefix}private_settings ps on ps.entity_guid = e.guid", "JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"), 'wheres' => array("ps.name = '{$priority}'"), 'order_by' => false, 'distinct' => false);
switch ($status) {
case 'active':
$options['relationship'] = 'active_plugin';
$options['relationship_guid'] = $site_guid;
$options['inverse_relationship'] = true;
break;
case 'inactive':
$options['wheres'][] = "NOT EXISTS (\n\t\t\t\t\t\tSELECT 1 FROM {$db_prefix}entity_relationships active_er\n\t\t\t\t\t\tWHERE active_er.guid_one = e.guid\n\t\t\t\t\t\t\tAND active_er.relationship = 'active_plugin'\n\t\t\t\t\t\t\tAND active_er.guid_two = {$site_guid})";
break;
case 'all':
default:
break;
}
$old_ia = elgg_set_ignore_access(true);
$plugins = elgg_get_entities_from_relationship($options);
elgg_set_ignore_access($old_ia);
usort($plugins, function (\ElggPlugin $a, \ElggPlugin $b) {
$a_value = $a->getVolatileData('select:value');
$b_value = $b->getVolatileData('select:value');
if ($b_value !== $a_value) {
return $a_value - $b_value;
} else {
return $a->guid - $b->guid;
}
});
return $plugins;
}