From 231a312a77f7f774b48fb5700bea780b274ed82a Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Thu, 31 Dec 2015 23:02:23 -0500 Subject: + Added class file for stage table --- app/class/stage.class.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/class/stage.class.php (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php new file mode 100644 index 0000000..a2dfba5 --- /dev/null +++ b/app/class/stage.class.php @@ -0,0 +1,25 @@ +<?php + +require_once "class/object.class.php"; + +/* + * Pad stages + */ +class Stage extends Object +{ + /* + * Constructor + */ + function __construct($guid = null) + { + $cols = array( + "guid", + "stage" + ); + + parent::__construct("stage", $cols); + $this->loadObj($guid); + } +} + +?> -- cgit v1.2.3 From ec7186ed4e1c2a41ff9052cdd1624b8cabbb047c Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Thu, 26 May 2016 23:46:22 -0400 Subject: Add copyright notice to Scrott class files --- app/class/stage.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index a2dfba5..1a2aadb 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -1,5 +1,19 @@ <?php +/* + * SCROTT Copyright (C) 2016 Malf Furious + * + * Scrott is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * Scrott is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + */ + require_once "class/object.class.php"; /* -- cgit v1.2.3 From ed99654d2e139a847a63e9295bf976d17462ee34 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> 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/stage.class.php | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 app/class/stage.class.php (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php deleted file mode 100644 index 1a2aadb..0000000 --- a/app/class/stage.class.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -/* - * SCROTT Copyright (C) 2016 Malf Furious - * - * Scrott is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, - * or (at your option) any later version. - * - * Scrott is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - */ - -require_once "class/object.class.php"; - -/* - * Pad stages - */ -class Stage extends Object -{ - /* - * Constructor - */ - function __construct($guid = null) - { - $cols = array( - "guid", - "stage" - ); - - parent::__construct("stage", $cols); - $this->loadObj($guid); - } -} - -?> -- cgit v1.2.3 From 5340dce8ad70a8cfc62116144f668f22845a2f31 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Wed, 5 Apr 2017 22:31:50 -0400 Subject: Add stage class --- app/class/stage.class.php | 137 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 app/class/stage.class.php (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php new file mode 100644 index 0000000..31f6a94 --- /dev/null +++ b/app/class/stage.class.php @@ -0,0 +1,137 @@ +<?php + +/* + * SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to UNLICENSE + */ + +require_once "class/object.class.php"; +require_once "class/pad.class.php"; + +/* + * This class models Scrott pad stages. Stages form a pipeline through + * which issues can progress. + */ +class stage extends object +{ + /* + * Constructor + */ + public function __construct(?string $guid = NULL) + { + $this->fields['stages'] = array( + "guid", + "stage", + ); + + parent::__construct($guid); + $this->expectType("stage"); + } + + /* + * Initialize a new stage object with the given name and parent + * pad. + */ + public static function initNew(string $name, pad $parent) : stage + { + $stage = new stage(); + $stage->setParent($parent); + $stage->name = $name; + $stage->objtype = "stage"; + return $stage; + } + + /* + * Get the stage following this one in the pipeline. NULL is + * returned if no stage is next. + */ + public function getNext() : ?stage + { + if (!isset($this->stage) || $this->stage == "") + return NULL; + + return new stage($this->stage); + } + + /* + * Get the stage preceding this one in the pipeline. NULL is + * returned if no stage is previous. + */ + public function getPrev() : ?stage + { + $pad = new pad($this->getParent()); + + if ($pad->stage == $this->guid) + return NULL; + + $query = "SELECT guid FROM stages WHERE stage = '" . database::esc($this->guid) . "'"; + $res = database::query($query); + + if (count($res) == 0) + return NULL; + + return new stage($res[0]['guid']); + } + + /* + * Get an array of all stages reachable from this one. The array + * is in proper order and includes the current stage. + */ + public function getArray() : array + { + $stages = array(); + $curr = $this; + + do $stages[] = $curr; + while (($curr = $curr->getNext())); + + return $stages; + } + + /* + * Reorder the stages of a pipeline by moving this one forward. + * This swaps the places of the current stage and the one following + * it. If this stage is the last in its pipeline, nothing is done + * and false is returned. + */ + public function moveForward() : bool + { + if (!($next = $this->getNext())) + return false; + + if (!($prev = $this->getPrev())) + $prev = new pad($this->getParent()); + + $tmp = $next->stage; + $prev->stage = $next->guid; + $next->stage = $this->guid; + $this->stage = $tmp; + + $next->saveObj(); + $prev->saveObj(); + return true; + } + + /* + * Reorder the stages of a pipeline by moving this one backward. + * This swaps the places of the current stage and the one preceding + * it. If this stage is the first in its pipeline, nothing is done + * and false is returned. + */ + public function moveBackward() : bool + { + if (!($prev = $this->getPrev())) + return false; + + return $prev->moveForward(); + } +} + +?> -- cgit v1.2.3 From 291b5a784e34099ece1839bf0bb3e8091c411576 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Fri, 7 Apr 2017 23:51:17 -0400 Subject: Update use of object getParent() function This function has been updated to construct and return the proper object type. This commit addresses the uses of this function so far to account for this. --- app/class/stage.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 31f6a94..150ac5d 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -66,7 +66,7 @@ class stage extends object */ public function getPrev() : ?stage { - $pad = new pad($this->getParent()); + $pad = $this->getParent(); if ($pad->stage == $this->guid) return NULL; @@ -107,7 +107,7 @@ class stage extends object return false; if (!($prev = $this->getPrev())) - $prev = new pad($this->getParent()); + $prev = $this->getParent(); $tmp = $next->stage; $prev->stage = $next->guid; -- cgit v1.2.3 From db7ad4f8943625e5c79fc09dae94a865f655493d Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Sat, 8 Apr 2017 02:36:07 -0400 Subject: Fix bug in stage moveForward() function Since this function is used by moveBackward(), failing to call $this->saveObj() would result in changes made to $this being lost. $this is now written back to the db every time and calling saveObj() manually when using moveBackward() can result in bad data being written to the db. --- app/class/stage.class.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 150ac5d..2616bee 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -116,6 +116,7 @@ class stage extends object $next->saveObj(); $prev->saveObj(); + $this->saveObj(); return true; } -- cgit v1.2.3 From dd3aeb526b497ccde45e7ba018e963f2e249387a Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Sat, 8 Apr 2017 23:00:56 -0400 Subject: Add stage function insertStage() --- app/class/stage.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 2616bee..1d21dcb 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -133,6 +133,17 @@ class stage extends object return $prev->moveForward(); } + + /* + * Insert a stage object in this pipeline, following $this object + */ + public function insertStage(stage $stage) : void + { + $stage->stage = $this->stage; + $this->stage = $stage->guid; + $stage->saveObj(); + $this->saveObj(); + } } ?> -- cgit v1.2.3 From 06e36d6b4009df47b0912c0f5b438171d153558f Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Sun, 9 Apr 2017 04:31:43 -0400 Subject: Add stage function getIssues_ordByDueByNumb() --- app/class/stage.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 1d21dcb..08a3708 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -95,6 +95,25 @@ class stage extends object return $stages; } + /* + * Get all issues in this stage, sorted by due date, then by + * issue number. + */ + public function getIssues_ordByDueByNumb() : array + { + $query = "SELECT o.guid FROM objects o JOIN issues i ON o.guid = i.guid " . + "WHERE o.objtype = 'issue' AND o.parent = '" . database::esc($this->guid) . + "' ORDER BY i.due, i.numb"; + $res = database::query($query); + + $issues = array(); + + foreach ($res as $i) + $issues[] = new issue($i['guid']); + + return $issues; + } + /* * Reorder the stages of a pipeline by moving this one forward. * This swaps the places of the current stage and the one following -- cgit v1.2.3 From 4cd8b4e9cac6ff104141cfb9154d11353cf9aab5 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Sun, 9 Apr 2017 04:44:09 -0400 Subject: Add stage function removeStage() --- app/class/stage.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 08a3708..1142bdd 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -163,6 +163,25 @@ class stage extends object $stage->saveObj(); $this->saveObj(); } + + /* + * Remove this stage object and move all of its issues. Issues are + * moved to the given stage object. Additionally, the pad may be + * given, in which case, those issues will be closed. + */ + public function removeStage(object $mvt) : void + { + if (!($prev = $this->getPrev())) + $prev = $this->getParent(); + + foreach ($this->getIssues_ordByDueByNumb() as $i) + $i->setParent($mvt); + + $prev->stage = $this->stage; + $prev->saveObj(); + + $this->delObj(); + } } ?> -- cgit v1.2.3 From d23eeb18e1604210dd55570c595fd184d8038f58 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Sun, 9 Apr 2017 14:41:39 -0400 Subject: Add missing require --- app/class/stage.class.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 1142bdd..1825546 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -14,6 +14,7 @@ require_once "class/object.class.php"; require_once "class/pad.class.php"; +require_once "class/issue.class.php"; /* * This class models Scrott pad stages. Stages form a pipeline through -- cgit v1.2.3 From 003f48ae880ad61eec65d9816d485457c45c4b11 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Sun, 9 Apr 2017 23:30:40 -0400 Subject: Fix bug in stage class --- app/class/stage.class.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 1825546..760a9a2 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -46,6 +46,7 @@ class stage extends object $stage->setParent($parent); $stage->name = $name; $stage->objtype = "stage"; + $stage->saveObj(); return $stage; } -- cgit v1.2.3 From 1b0d75037fa9c0b8e8f0265da348b2238a332931 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Thu, 13 Apr 2017 21:09:46 -0400 Subject: Update stage function moveBackward() Now calling refreshObj() to update altered pointers. --- app/class/stage.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 760a9a2..74c5f42 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.class.php @@ -152,7 +152,9 @@ class stage extends object if (!($prev = $this->getPrev())) return false; - return $prev->moveForward(); + $ret = $prev->moveForward(); + $this->refreshObj(); + return $ret; } /* -- cgit v1.2.3 From e54418762e279a1d7ca0efb7ed89b95464753ee8 Mon Sep 17 00:00:00 2001 From: Malf Furious <m@lfurio.us> Date: Wed, 7 Feb 2018 22:33:19 -0500 Subject: Update class files to use renamed obj class --- app/class/stage.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/class/stage.class.php') diff --git a/app/class/stage.class.php b/app/class/stage.class.php index 74c5f42..43bb3c3 100644 --- a/app/class/stage.class.php +++ b/app/class/stage.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/pad.class.php"; require_once "class/issue.class.php"; @@ -20,7 +20,7 @@ require_once "class/issue.class.php"; * This class models Scrott pad stages. Stages form a pipeline through * which issues can progress. */ -class stage extends object +class stage extends obj { /* * Constructor @@ -173,7 +173,7 @@ class stage extends object * moved to the given stage object. Additionally, the pad may be * given, in which case, those issues will be closed. */ - public function removeStage(object $mvt) : void + public function removeStage(obj $mvt) : void { if (!($prev = $this->getPrev())) $prev = $this->getParent(); -- cgit v1.2.3