From 07125786f7d6fbe1b394141a2cdd983af7092f12 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 20 Mar 2011 20:06:11 +0000 Subject: Refs #2892 added elgg_get_admins() function - this could eventually be a wrapper around elgg_get_users() git-svn-id: http://code.elgg.org/elgg/trunk@8783 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'engine') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index efb1a4581..71bf8fe12 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -7,6 +7,38 @@ * @subpackage Core */ +/** + * Get the admin users + * + * @param array $options Options array, @see elgg_get_entities() for parameters + * + * @return mixed Array of admin users or false on failure. If a count, returns int. + * @since 1.8.0 + */ +function elgg_get_admins(array $options = array()) { + global $CONFIG; + + if (isset($options['joins'])) { + if (!is_array($options['joins'])) { + $options['joins'] = array($options['joins']); + } + $options['joins'][] = "join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid"; + } else { + $options['joins'] = array("join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid"); + } + + if (isset($options['wheres'])) { + if (!is_array($options['wheres'])) { + $options['wheres'] = array($options['wheres']); + } + $options['wheres'][] = "u.admin = 'yes'"; + } else { + $options['wheres'][] = "u.admin = 'yes'"; + } + + return elgg_get_entities($options); +} + /** * Write a persistent message to the admin view. * Useful to alert the admin to take a certain action. -- cgit v1.2.3