]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2892 added elgg_get_admins() function - this could eventually be a wrapper...
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 20 Mar 2011 20:06:11 +0000 (20:06 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 20 Mar 2011 20:06:11 +0000 (20:06 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8783 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/admin.php

index efb1a458140958d1d6e9efa97eea09858c6511d0..71bf8fe124ea5a0095ee87a8d428b90f6f3313cf 100644 (file)
@@ -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.