aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-27 02:32:46 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-27 02:32:46 +0000
commit6f368445a5a8f752dcdbafe229921b5723dc805f (patch)
treebed93eccf51757ff6bd99269d94a346cef5f7800 /engine/lib/elgglib.php
parent68ce78d622a1fb8c5ee002b5efc06b05a7b4555d (diff)
downloadelgg-6f368445a5a8f752dcdbafe229921b5723dc805f.tar.gz
elgg-6f368445a5a8f752dcdbafe229921b5723dc805f.tar.bz2
Created elgg_get_entities_from_metadata() and made get_entities_from_metadata().
Made elgg_get_entities() accept extra joins and wheres in the options. Created a helper function elgg_normalise_plural_options_array() to rewrite shortcut singular options to plurals. git-svn-id: http://code.elgg.org/elgg/trunk@3584 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 351750b0b..2eecfefb6 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -2123,6 +2123,37 @@ function is_not_null($string) {
return true;
}
+
+/**
+ * Normalise the singular keys in an options array
+ * to the plural keys.
+ *
+ * @param $options
+ * @param $singulars
+ * @return array
+ */
+function elgg_normalise_plural_options_array($options, $singulars) {
+ foreach ($singulars as $singular) {
+ $plural = $singular . 's';
+
+ // normalize the singular to plural
+ if (isset($options[$singular]) && $options[$singular] !== NULL && $options[$singular] !== FALSE) {
+ if (isset($options[$plural])) {
+ if (is_array($options[$plural])) {
+ $options[$plural][] = $options[$singlar];
+ } else {
+ $options[$plural] = array($options[$plural], $options[$singular]);
+ }
+ } else {
+ $options[$plural] = array($options[$singular]);
+ }
+ }
+ $options[$singular] = NULL;
+ }
+
+ return $options;
+}
+
/**
* Get the full URL of the current page.
*