aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
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.
*