summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-04-09 20:08:05 -0400
committerMalf Furious <m@lfurio.us>2017-04-09 20:08:05 -0400
commitcc1f573a276bd5f022831f837bb9c1234df56ad9 (patch)
tree5ec523ccfb48e39b569f6a2adbcaed0806cce805 /app
parentc4c3b3f73b1750de703213a20664dea9742ac825 (diff)
downloadscrott-cc1f573a276bd5f022831f837bb9c1234df56ad9.tar.gz
scrott-cc1f573a276bd5f022831f837bb9c1234df56ad9.zip
Add agent function getPads_ordByOwnByName()
Diffstat (limited to 'app')
-rw-r--r--app/class/agent.class.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/class/agent.class.php b/app/class/agent.class.php
index 038c485..a2c8c2e 100644
--- a/app/class/agent.class.php
+++ b/app/class/agent.class.php
@@ -13,6 +13,7 @@
*/
require_once "class/object.class.php";
+require_once "class/pad.class.php";
/*
* This is a supertype for users and groups, since these two object types
@@ -69,6 +70,35 @@ abstract class agent extends object
}
/*
+ * Get all pads this agent owns or is a member of. This isn't
+ * necessarily all pads this agent has access permission for.
+ * Results are sorted by ownership, then by name.
+ */
+ public function getPads_ordByOwnByName() : array
+ {
+ $pads = array();
+
+ /* owner */
+ $query = "SELECT guid FROM objects WHERE objtype = 'pad' AND " .
+ "owner = '" . database::esc($this->guid) . "' ORDER BY name";
+ $res = database::query($query);
+
+ foreach ($res as $p)
+ $pads[] = new pad($p['guid']);
+
+ /* members */
+ $query = "SELECT o.guid FROM objects o JOIN members m ON " .
+ "o.guid = m.guid WHERE o.objtype = 'pad' AND " .
+ "m.member = '" . database::esc($this->guid) . "' ORDER BY o.name";
+ $res = database::query($query);
+
+ foreach ($res as $p)
+ $pads[] = new pad($p['guid']);
+
+ return $pads;
+ }
+
+ /*
* Check whether this agent has access permission for given
* object
*/