From a8e79321426b1436f46ba5b7c5dee390c94bdb8b Mon Sep 17 00:00:00 2001
From: Malf Furious <m@lfurio.us>
Date: Sun, 4 Jun 2017 20:57:12 -0400
Subject: Move function getMesgs() into object class

This function is needed in the scope of issue, mesgs, and pads alike.
It would also make sense to use this to retrive users' private messages.
For these reasons, this function is now being defined higher up in the
object hierarchy.
---
 app/class/object.class.php | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

(limited to 'app/class/object.class.php')

diff --git a/app/class/object.class.php b/app/class/object.class.php
index 7c80b5b..461f1b1 100644
--- a/app/class/object.class.php
+++ b/app/class/object.class.php
@@ -162,6 +162,24 @@ class object extends table
         return true;
     }
 
+    /*
+     * Get all messages on this object.  Messages are sorted by date
+     * created.
+     */
+    public function getMesgs_ordByDatetime() : array
+    {
+        $query = "SELECT guid FROM objects WHERE objtype = 'mesg' AND " .
+            "parent = '" . database::esc($this->guid) . "' ORDER BY created";
+        $res = database::query($query);
+
+        $mesgs = array();
+
+        foreach ($res as $m)
+            $mesgs[] = new mesg($m['guid']);
+
+        return $mesgs;
+    }
+
     /*
      * Get the URL to the head image resource for this object
      */
-- 
cgit v1.2.3