Skip to content

Instantly share code, notes, and snippets.

@hypeJunction
Last active June 25, 2016 16:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hypeJunction/c3984ac3ba870abd206a to your computer and use it in GitHub Desktop.
Save hypeJunction/c3984ac3ba870abd206a to your computer and use it in GitHub Desktop.
Elgg 1.9 - show hidden/disabled entities
<?php
namespace MyPlugin;
elgg_register_plugin_hook_handler('get_sql', 'access', __NAMESPACE__ . '\\filter_access_sql');
/**
* Filter access sql to display disabled entities
*
* @param string $hook 'get_sql'
* @param string $type 'access'
* @param array $clauses
* @param array $params
* @return array
*/
function filter_access_sql($hook, $type, $clauses, $params) {
if (!elgg_in_context('show_hidden_entities')) {
return $clauses;
}
$table_alias = elgg_extract('table_alias', $params);
$table_alias = ($table_alias) ? "{$table_alias}." : "";
$and_clauses = elgg_extract('ands', $clauses, array());
if (is_array($and_clauses)) {
foreach ($and_clauses as $key => $clause) {
if ($clause == "{$table_alias}enabled = 'yes'") {
unset($clauses['ands'][$key]);
}
}
}
return $clauses;
}
elgg_push_context('show_hidden_entities');
// do things to hidden/disabled entities
elgg_pop_context();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment