From 3231db3d578c510d130b1377d3809228a273b118 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 31 Dec 2015 20:13:26 -0500 Subject: + Added class file for Pad table --- app/class/pad.class.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/class/pad.class.php (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php new file mode 100644 index 0000000..335ef63 --- /dev/null +++ b/app/class/pad.class.php @@ -0,0 +1,26 @@ +loadObj($guid); + } +} + +?> -- cgit v1.2.3 From ec7186ed4e1c2a41ff9052cdd1624b8cabbb047c Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 26 May 2016 23:46:22 -0400 Subject: Add copyright notice to Scrott class files --- app/class/pad.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php index 335ef63..32994e5 100644 --- a/app/class/pad.class.php +++ b/app/class/pad.class.php @@ -1,5 +1,19 @@ Date: Sat, 22 Oct 2016 00:29:30 -0400 Subject: Deprecate application code Setup to perform an iteration of development focused on a simpler implementation and eliminating redundancy in design. --- app/class/pad.class.php | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 app/class/pad.class.php (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php deleted file mode 100644 index 32994e5..0000000 --- a/app/class/pad.class.php +++ /dev/null @@ -1,40 +0,0 @@ -loadObj($guid); - } -} - -?> -- cgit v1.2.3 From 9668df9d17f343bf8a130bd8b50a977485a926c8 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 29 Mar 2017 01:34:07 -0400 Subject: Add pad class --- app/class/pad.class.php | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 app/class/pad.class.php (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php new file mode 100644 index 0000000..7c53f30 --- /dev/null +++ b/app/class/pad.class.php @@ -0,0 +1,87 @@ +fields['pads'] = array( + "guid", + "stage", + "issueNumb", + ); + + parent::__construct($guid); + $this->expectType("pad"); + } + + /* + * Get an array of all pads, sorted by name + */ + public static function getAll_ordByName() : array + { + $query = "SELECT guid FROM objects WHERE objtype = 'pad' ORDER BY name"; + $res = database::query($query); + + $pads = array(); + + foreach ($res as $p) + $pads[] = new pad($p['guid']); + + return $pads; + } + + /* + * Get an array of all pads NOT owned by a group. These are root-level + * pads. Results are sorted by name. + */ + public static function getAllNoGroup_ordByName() : array + { + $query = "SELECT o.guid FROM objects o JOIN objects b ON o.owner = b.guid WHERE o.objtype = 'pad' AND " . + "b.objtype = 'user' ORDER BY o.name"; + $res = database::query($query); + + $pads = array(); + + foreach ($res as $p) + $pads[] = new pad($p['guid']); + + return $pads; + } + + /* + * Initialize a new pad object with the given name and owner + */ + public static function initNew(string $name, agent $owner) : pad + { + $pad = new pad(); + $pad->setOwner($owner); + $pad->name = $name; + $pad->objtype = "pad"; + $pad->issueNumb = 0; + return $pad; + } +} + +?> -- cgit v1.2.3 From 478504986a348bb53765e137a6ea8293929954aa Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 9 Apr 2017 15:01:54 -0400 Subject: Add pad function insertStage() --- app/class/pad.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php index 7c53f30..d062b0c 100644 --- a/app/class/pad.class.php +++ b/app/class/pad.class.php @@ -14,6 +14,7 @@ require_once "class/object.class.php"; require_once "class/agent.class.php"; +require_once "class/stage.class.php"; /* * This class models Scrott pads. Pads are the space for projects to track @@ -82,6 +83,17 @@ class pad extends object $pad->issueNumb = 0; return $pad; } + + /* + * Insert a stage object at the front of this pad's pipeline + */ + public function insertStage(stage $stage) : void + { + $stage->stage = $this->stage; + $this->stage = $stage->guid; + $stage->saveObj(); + $this->saveObj(); + } } ?> -- cgit v1.2.3 From 8a1a277c3cf747cbb82c9dcb660a925963f635a5 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 9 Apr 2017 17:48:27 -0400 Subject: Add pad function getStages() --- app/class/pad.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php index d062b0c..a5c771b 100644 --- a/app/class/pad.class.php +++ b/app/class/pad.class.php @@ -84,6 +84,16 @@ class pad extends object return $pad; } + /* + * Get an array of all stages under this pad. The array is in + * proper sequential order. + */ + public function getStages() : array + { + $stage = new stage($this->stage); + return $stage->getArray(); + } + /* * Insert a stage object at the front of this pad's pipeline */ -- cgit v1.2.3 From adf93dfd11483d69ad4bc823a2b936df270d951d Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 9 Apr 2017 23:25:25 -0400 Subject: Fix bug in pad class --- app/class/pad.class.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php index a5c771b..3966f58 100644 --- a/app/class/pad.class.php +++ b/app/class/pad.class.php @@ -81,6 +81,7 @@ class pad extends object $pad->name = $name; $pad->objtype = "pad"; $pad->issueNumb = 0; + $pad->saveObj(); return $pad; } -- cgit v1.2.3 From e54418762e279a1d7ca0efb7ed89b95464753ee8 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 7 Feb 2018 22:33:19 -0500 Subject: Update class files to use renamed obj class --- app/class/pad.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php index 3966f58..38812d6 100644 --- a/app/class/pad.class.php +++ b/app/class/pad.class.php @@ -12,7 +12,7 @@ * For more information, please refer to UNLICENSE */ -require_once "class/object.class.php"; +require_once "class/obj.class.php"; require_once "class/agent.class.php"; require_once "class/stage.class.php"; @@ -20,7 +20,7 @@ require_once "class/stage.class.php"; * This class models Scrott pads. Pads are the space for projects to track * issues and communicate. */ -class pad extends object +class pad extends obj { /* * Constructor -- cgit v1.2.3 From d16ddc164b82c594680359841eeeaa1e26aceaa1 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 20 Sep 2018 00:28:17 -0400 Subject: pad: Fix bug in function getStages() In cases where the pad had no stages beneath it, `new stage($this->stage)` would construct an invalid object. As it turns out, calling ->getArray() on an uninitialized stage object yeilds bad results. Instead of patching the stage::getArray() function, I add a check to harden pad::getStages(). My reasoning for this is as follows: The bug in getArray() manifests from a domain error, ie. it's only because we are calling it on an uninitialized object. The object is already in a bad state prior to caling getArray(). Rather, I opt to patch getStages() so that we never create a bad object in the first place. Now, for no-stage pads, getStages() will return early an empty array. --- app/class/pad.class.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/class/pad.class.php') diff --git a/app/class/pad.class.php b/app/class/pad.class.php index 38812d6..dcf2b32 100644 --- a/app/class/pad.class.php +++ b/app/class/pad.class.php @@ -91,6 +91,9 @@ class pad extends obj */ public function getStages() : array { + if (!isset($this->stage) || $this->stage == "") + return array(); + $stage = new stage($this->stage); return $stage->getArray(); } -- cgit v1.2.3