summaryrefslogtreecommitdiffstats
path: root/app/class/object.class.php
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-06-20 00:17:17 -0400
committerMalf Furious <m@lfurio.us>2017-06-20 00:17:17 -0400
commita4d96f0c1e9dd89df3dd189664f400680eb4e8fa (patch)
treeba0e0b0c02a7c3384306a38106ac6eebdb80b4f4 /app/class/object.class.php
parent2376aabe74528b018189982224d61a643325b114 (diff)
parent2564b9953bb7bd8e90a9865962cb9e88d4cfd218 (diff)
downloadscrott-a4d96f0c1e9dd89df3dd189664f400680eb4e8fa.tar.gz
scrott-a4d96f0c1e9dd89df3dd189664f400680eb4e8fa.zip
Merge branch 'feature/email' into dev
Diffstat (limited to 'app/class/object.class.php')
-rw-r--r--app/class/object.class.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/class/object.class.php b/app/class/object.class.php
index 461f1b1..c1ba85c 100644
--- a/app/class/object.class.php
+++ b/app/class/object.class.php
@@ -71,6 +71,32 @@ class object extends table
}
/*
+ * Remove duplicate elements from an array of Scrott objects. This
+ * function compares object GUIDs to check for uniqueness. Array
+ * keys are preserved. NULL elements are removed. Resulting array
+ * is returned.
+ */
+ public static function arrayUnique(array $arr) : array
+ {
+ $guids = array();
+ $ret = array();
+
+ foreach ($arr as $k => $v)
+ {
+ if ($v === NULL)
+ continue;
+
+ if (in_array($v->guid, $guids))
+ continue;
+
+ $guids[] = $v->guid;
+ $ret[$k] = $v;
+ }
+
+ return $ret;
+ }
+
+ /*
* Get the owner of this object. Either a user object or a group
* object will be returned. If this object does not have an owner,
* NULL will be returned.