From c139f96610ba12f5035f1c3a18448a290714d851 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Fri, 1 Jan 2016 00:08:50 -0500 Subject: + Added class file for issue table --- app/class/issue.class.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/class/issue.class.php (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php new file mode 100644 index 0000000..90a095c --- /dev/null +++ b/app/class/issue.class.php @@ -0,0 +1,28 @@ +loadObj($guid); + } +} + +?> -- cgit v1.2.3 From f7e765480572920ba396a747f0294c75ab813202 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 7 Feb 2016 15:11:25 -0500 Subject: Add fields to Issue object This adds attributes to an issue: due date (optional datetime) tags (space separated string of words to help categorize issues (again, optional)) --- app/class/issue.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 90a095c..67bf683 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -17,7 +17,9 @@ class Issue extends Object "number", "assignee", "unread", - "desc" + "desc", + "due", + "tags" ); parent::__construct("issue", $cols); -- 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/issue.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 67bf683..10b1661 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.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/issue.class.php | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 app/class/issue.class.php (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php deleted file mode 100644 index 10b1661..0000000 --- a/app/class/issue.class.php +++ /dev/null @@ -1,44 +0,0 @@ -loadObj($guid); - } -} - -?> -- cgit v1.2.3 From 37db482851a7724520e5db7aef89dcd8490cc081 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 1 Jun 2017 23:35:44 -0400 Subject: Add issue class --- app/class/issue.class.php | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 app/class/issue.class.php (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php new file mode 100644 index 0000000..e439dff --- /dev/null +++ b/app/class/issue.class.php @@ -0,0 +1,117 @@ +fields['issues'] = array( + "guid", + "numb", + "assignee", + "seen", + "description", + "due", + "tags", + ); + + parent::__construct($guid); + $this->expectType("issue"); + } + + /* + * Initialize a new issue object with the given name, parent, and + * owner. + */ + public static function initNew(string $name, user $owner, stage $parent) : issue + { + $pad = $parent->getParent(); + $numb = $pad->issueNumb++; + $pad->saveObj(); + + $issue = new issue(); + $issue->setOwner($owner); + $issue->setParent($parent); + $issue->name = $name; + $issue->objtype = "issue"; + $issue->numb = $numb; + $issue->saveObj(); + return $issue; + } + + /* + * Get all activity for this issue. 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; + } + + /* + * Reset the seen flag and reassign this issue. + */ + public function assignTo(user $assignee) : void + { + $this->seen = 0; + $this->assignee = $assignee->guid; + $this->saveObj(); + } + + /* + * Advance this issue in the pipeline, closing it if already in the + * last stage. + */ + public function advance() : void + { + $stage = $this->getParent(); + + if (!($next = $stage->getNext())) + $this->close(); + + $this->setParent($next); + } + + /* + * Mark this issue as completed and closed. + */ + public function close() : void + { + $pad = $this->getParent()->getParent(); + $this->setParent($pad); + } +} + +?> -- cgit v1.2.3 From eb4b42f32856b0e5616b700614c8c68d77cd0ea3 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 3 Jun 2017 17:24:31 -0400 Subject: issue: Fix bug in function advance() The call to setParent() should have been in an else. It was being called every time... --- app/class/issue.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index e439dff..1286e1a 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -100,8 +100,8 @@ class issue extends object if (!($next = $stage->getNext())) $this->close(); - - $this->setParent($next); + else + $this->setParent($next); } /* -- cgit v1.2.3 From da90fc87384b1daa8104cdea14fb1b52f0f747b7 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 3 Jun 2017 17:31:16 -0400 Subject: issue: Fix bug in functions advance() and close() If the issue is already closed, these functions should do nothing. Continuing the logic in these functions could currupt the database. --- app/class/issue.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 1286e1a..3127a87 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -98,6 +98,9 @@ class issue extends object { $stage = $this->getParent(); + if ($stage->objtype != "stage") + return; + if (!($next = $stage->getNext())) $this->close(); else @@ -110,7 +113,9 @@ class issue extends object public function close() : void { $pad = $this->getParent()->getParent(); - $this->setParent($pad); + + if ($pad) + $this->setParent($pad); } } -- cgit v1.2.3 From a8e79321426b1436f46ba5b7c5dee390c94bdb8b Mon Sep 17 00:00:00 2001 From: Malf Furious 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/issue.class.php | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 3127a87..6056457 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -62,24 +62,6 @@ class issue extends object return $issue; } - /* - * Get all activity for this issue. 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; - } - /* * Reset the seen flag and reassign this issue. */ -- cgit v1.2.3 From fa929cbd64d662126b8734e476bdbbf3562333d4 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 13 Jun 2017 21:56:58 -0400 Subject: Add issue function getAssignee() --- app/class/issue.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 6056457..c3381a7 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -62,6 +62,17 @@ class issue extends object return $issue; } + /* + * Get the assignee for this issue + */ + public function getAssignee() : ?user + { + if (!isset($this->assignee) || $this->assignee == "") + return NULL; + + return new user($this->assignee); + } + /* * Reset the seen flag and reassign this issue. */ -- cgit v1.2.3 From d840a3d9b464ac424d210aeffc01cea0a774377b Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 13 Jun 2017 22:03:24 -0400 Subject: Add issue function getPad() --- app/class/issue.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index c3381a7..b61a6e3 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -83,6 +83,19 @@ class issue extends object $this->saveObj(); } + /* + * Get the pad this issue exists under + */ + public function getPad() : pad + { + $parent = $this->getParent(); + + if ($parent->objtype == "pad") + return $parent; + + return $parent->getParent(); + } + /* * Advance this issue in the pipeline, closing it if already in the * last stage. -- 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/issue.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index b61a6e3..1c77894 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.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/stage.class.php"; require_once "class/user.class.php"; require_once "class/mesg.class.php"; @@ -21,7 +21,7 @@ require_once "class/mesg.class.php"; * This class models Scrott issues. Issues represent units of work, can * be assigned to users, and advance through a pipeline. */ -class issue extends object +class issue extends obj { /* * Constructor -- cgit v1.2.3 From 9df5344050ec0a2b8bec03c7a89fff9d7d41ce2f Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 20 Oct 2018 21:24:01 -0400 Subject: issue: Add author and authored fields --- app/class/issue.class.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 1c77894..651096e 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -32,8 +32,10 @@ class issue extends obj "guid", "numb", "assignee", + "author", "seen", "description", + "authored", "due", "tags", ); @@ -58,6 +60,9 @@ class issue extends obj $issue->name = $name; $issue->objtype = "issue"; $issue->numb = $numb; + $issue->setAuthor($owner); + $issue->saveObj(); // get timestamp + $issue->authored = $issue->created; $issue->saveObj(); return $issue; } @@ -83,6 +88,30 @@ class issue extends obj $this->saveObj(); } + /* + * Get the author of this issue. This is usually the user + * that opened the issue, but may differ if this issue was + * elevated from a previous discussion thread. + */ + public function getAuthor() : user + { + if (!isset($this->author) || $this->author == "") + return NULL; + + return new user($this->author); + } + + /* + * Set the author of this issue. This should usually only + * be done while constructing a new message or to clear out + * references to a user that got removed. + */ + public function setAuthor(user $author) : void + { + $this->author = $author->guid; + $this->saveObj(); + } + /* * Get the pad this issue exists under */ -- cgit v1.2.3 From b093b3affe3ac6878e2242bff310dc466687a825 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 20 Oct 2018 21:43:46 -0400 Subject: issue: Add open/close data --- app/class/issue.class.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 651096e..5d1daec 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -33,9 +33,12 @@ class issue extends obj "numb", "assignee", "author", + "closer", "seen", "description", + "opened", "authored", + "closed", "due", "tags", ); @@ -62,6 +65,7 @@ class issue extends obj $issue->numb = $numb; $issue->setAuthor($owner); $issue->saveObj(); // get timestamp + $issue->opened = $issue->created; $issue->authored = $issue->created; $issue->saveObj(); return $issue; @@ -112,6 +116,27 @@ class issue extends obj $this->saveObj(); } + /* + * Get the user that closed this issue. If the issue is still + * open, NULL is returned. + */ + public function getCloser() : ?user + { + if (!isset($this->closer) || $this->closer == "") + return NULL; + + return new user($this->closer); + } + + /* + * Mark the user that closed this issue. + */ + public function setCloser(user $closer) : void + { + $this->closer = $closer->guid; + $this->saveObj(); + } + /* * Get the pad this issue exists under */ @@ -145,12 +170,16 @@ class issue extends obj /* * Mark this issue as completed and closed. */ - public function close() : void + public function close(user $closer) : void { $pad = $this->getParent()->getParent(); if ($pad) + { + $this->closed = self::getCurrentTimestamp(); + $this->setCloser($closer); $this->setParent($pad); + } } } -- cgit v1.2.3 From b690505b0e1e255e5081adcf49c724186bb831c2 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 20 Oct 2018 21:49:32 -0400 Subject: issue: Add assigned timestamp --- app/class/issue.class.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 5d1daec..57fc588 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -37,6 +37,7 @@ class issue extends obj "seen", "description", "opened", + "assigned", "authored", "closed", "due", @@ -89,6 +90,7 @@ class issue extends obj { $this->seen = 0; $this->assignee = $assignee->guid; + $this->assigned = self::getCurrentTimestamp(); $this->saveObj(); } -- cgit v1.2.3 From 792e741899cc895651e7b12a38b688c1da6406db Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 20 Oct 2018 21:55:53 -0400 Subject: issue: Add function isOpen() --- app/class/issue.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 57fc588..0fc12e4 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -183,6 +183,14 @@ class issue extends obj $this->setParent($pad); } } + + /* + * Check whether issue is currently open or closed. + */ + public function isOpen() : bool + { + return self::typeOf($this->parent) != "pad"; + } } ?> -- cgit v1.2.3 From a18205b9991f9e5d6ac0a86aa37f049bf53980f6 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 21 Oct 2018 21:59:55 -0400 Subject: issue: Rewrite issue class Revised implementation of redesigned data model. --- app/class/issue.class.php | 179 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 125 insertions(+), 54 deletions(-) (limited to 'app/class/issue.class.php') diff --git a/app/class/issue.class.php b/app/class/issue.class.php index 0fc12e4..47adfa1 100644 --- a/app/class/issue.class.php +++ b/app/class/issue.class.php @@ -18,8 +18,8 @@ require_once "class/user.class.php"; require_once "class/mesg.class.php"; /* - * This class models Scrott issues. Issues represent units of work, can - * be assigned to users, and advance through a pipeline. + * This class models Scrott issues. Issues represent units of work, track + * messages, can be assigned to users, and advance through a pipeline. */ class issue extends obj { @@ -31,14 +31,8 @@ class issue extends obj $this->fields['issues'] = array( "guid", "numb", - "assignee", - "author", + "mesg", "closer", - "seen", - "description", - "opened", - "assigned", - "authored", "closed", "due", "tags", @@ -49,10 +43,11 @@ class issue extends obj } /* - * Initialize a new issue object with the given name, parent, and - * owner. + * Initialize a new issue object with the given message, parent, + * and owner. The issue's name is taken from the message's name. + * The given message object is updated to parent the new issue. */ - public static function initNew(string $name, user $owner, stage $parent) : issue + public static function initNew(mesg $mesg, user $owner, stage $parent) : issue { $pad = $parent->getParent(); $numb = $pad->issueNumb++; @@ -61,61 +56,146 @@ class issue extends obj $issue = new issue(); $issue->setOwner($owner); $issue->setParent($parent); - $issue->name = $name; + $issue->name = $mesg->name; $issue->objtype = "issue"; $issue->numb = $numb; - $issue->setAuthor($owner); - $issue->saveObj(); // get timestamp - $issue->opened = $issue->created; - $issue->authored = $issue->created; + $issue->mesg = $mesg->guid; $issue->saveObj(); + + $mesg->setParent($issue); + return $issue; } /* - * Get the assignee for this issue + * Get all assignees. Assignees are returned as an array of + * stdClass instances. Objects contain data from the 'assignees' + * database table with no defined operations. Pointers to users + * will be followed and an instanciated user object will be + * in their place. Limit of zero returns all assignees. */ - public function getAssignee() : ?user + public function getAssignees(int $limit = 0) : array { - if (!isset($this->assignee) || $this->assignee == "") - return NULL; + $assign = array(); + $query = "SELECT * FROM assignees WHERE guid = '" . + database::esc($this->guid) . "'"; + + if ($limit != 0) + $query .= " LIMIT " . database::esc($limit); + + $res = database::query($query); + + foreach ($res as $a) + { + $obj = new stdClass(); + + foreach ($a as $k => $v) + $obj->{$k} = $v; + + $obj->assignee = new user($obj->assignee); + $obj->assigner = new user($obj->assigner); + + if (isset($obj->dismisser) && $obj->dismisser != "") + $obj->dismisser = new user($obj->dismisser); - return new user($this->assignee); + $assign[] = $obj; + } + + return $assign; } /* - * Reset the seen flag and reassign this issue. + * Add an assignee to this issue. Returns false if user is + * already assigned, or if another error occurs; true + * otherwise. */ - public function assignTo(user $assignee) : void + public function addAssignee(user $assignee, user $assigner) : bool { - $this->seen = 0; - $this->assignee = $assignee->guid; - $this->assigned = self::getCurrentTimestamp(); - $this->saveObj(); + if ($assignee->isAssignedTo($this) || !isset($assignee->guid) + || !isset($assigner->guid)) + return false; + + $query = "INSERT INTO assignees (guid, assignee, assigner, assigned)" . + " VALUES ('" . database::esc($this->guid) . "', '" . + database::esc($assignee->guid) . "', '" . database::esc($assigner->guid) . + "', '" . database::esc(self::getCurrentTimestamp()) . "')"; + + database::query($query); + return true; } /* - * Get the author of this issue. This is usually the user - * that opened the issue, but may differ if this issue was - * elevated from a previous discussion thread. + * Dismiss an assignee, effectively unassigning them. Returns + * false if user is not already an active assignee, or if another + * error occurs; true otherwise. */ - public function getAuthor() : user + public function dismissAssignee(user $assignee, user $dismisser) : bool { - if (!isset($this->author) || $this->author == "") - return NULL; + if (!$assignee->isAssignedTo($this) || !isset($assignee->guid) + || !isset($dismisser->guid)) + return false; + + $query = "UPDATE assignees SET dismisser = '" . database::esc($dismisser->guid) . + "', dismissed = '" . database::esc(self::getCurrentTimestamp()) . + "' WHERE guid = '" . database::esc($this->guid) . "' AND assignee = '" . + database::esc($assignee->guid) . "'"; + + database::query($query); + return true; + } + + /* + * Signoff an assignee's portion of this issue. Returns false + * if user is not already an active assignee, or if another + * error occurs; true otherwise. + */ + public function signoffAssignee(user $assignee) : bool + { + if (!$assignee->isAssignedTo($this) || !isset($assignee->guid)) + return false; + + $query = "UPDATE assignees SET signedoff = '" . + database::esc(self::getCurrentTimestamp()) . "' WHERE guid = '" . + database::esc($this->guid) . "' AND assignee = '" . + database::esc($assignee->guid) . "'"; + + database::query($query); + return true; + } - return new user($this->author); + /* + * Get the OP message for this issue. + */ + public function getOPMesg() : mesg + { + return new mesg($this->mesg); } /* - * Set the author of this issue. This should usually only - * be done while constructing a new message or to clear out - * references to a user that got removed. + * Get all messages on this issue. The OP message is filtered + * from results. Messages are sorted by date created. */ - public function setAuthor(user $author) : void + public function getMesgs_ordByDatetime() : array { - $this->author = $author->guid; - $this->saveObj(); + $mesgs = parent::getMesgs_ordByDatetime(); + $i = -1; + + foreach ($mesgs as $k => $m) + { + if ($m->guid == $this->mesg) + { + $i = $k; + break; + } + } + + if ($i != -1) + { + unset($mesgs[$i]); + $mesgs = array_values($mesgs); + } + + return $mesgs; } /* @@ -130,15 +210,6 @@ class issue extends obj return new user($this->closer); } - /* - * Mark the user that closed this issue. - */ - public function setCloser(user $closer) : void - { - $this->closer = $closer->guid; - $this->saveObj(); - } - /* * Get the pad this issue exists under */ @@ -154,9 +225,9 @@ class issue extends obj /* * Advance this issue in the pipeline, closing it if already in the - * last stage. + * last stage. A closer is needed incase a close takes place. */ - public function advance() : void + public function advance(user $closer) : void { $stage = $this->getParent(); @@ -164,7 +235,7 @@ class issue extends obj return; if (!($next = $stage->getNext())) - $this->close(); + $this->close($closer); else $this->setParent($next); } @@ -178,8 +249,8 @@ class issue extends obj if ($pad) { + $this->closer = $closer->guid; $this->closed = self::getCurrentTimestamp(); - $this->setCloser($closer); $this->setParent($pad); } } -- cgit v1.2.3