From d21f6ba14c8e15a5d0d44f82bea35c9e89eabbb9 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Wed, 31 May 2023 03:39:24 +0300 Subject: manage petitions; in progress --- public/app/models/Content_model.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'public/app/models/Content_model.php') diff --git a/public/app/models/Content_model.php b/public/app/models/Content_model.php index ea19165..2a79159 100644 --- a/public/app/models/Content_model.php +++ b/public/app/models/Content_model.php @@ -53,17 +53,30 @@ class Content_model { /** user petitions * - * get all petitions of a user + * get all petitions of a user; * * @param int $uid: user id * @return array petition records */ public static function user_petitions($uid) { - return Registry::use('database')->runQuery( + $list = Registry::use('database')->runQuery( "SELECT * FROM petition WHERE user_id = :uid", [ ':uid' => $uid ] ); + + $results = []; // re-format results + foreach($list as $key => $rec) { + $results[] = [ + 'id' => $rec['id'], + 'type_id' => $rec['type_id'], + 'subject' => $rec['subject'], + 'signature' => $rec['signature'], + 'protocol' => $rec['protocol'] ?? '', + 'form_structure' => unserialize($rec['form_structure']) + ]; + } + return $results; } -- cgit v1.2.3