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 ++++++++++++++++++++++++++++++- srvs/mysql.sql | 3 +++ 2 files changed, 33 insertions(+), 1 deletion(-) 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); + } } } diff --git a/srvs/mysql.sql b/srvs/mysql.sql index 178fb57..9f3193b 100644 --- a/srvs/mysql.sql +++ b/srvs/mysql.sql @@ -181,9 +181,12 @@ CREATE TABLE issues ( numb int(32) NOT NULL DEFAULT 0, assignee varchar(8) NOT NULL DEFAULT '', author varchar(8) NOT NULL DEFAULT '', + closer varchar(8) NOT NULL DEFAULT '', seen int(1) NOT NULL DEFAULT 0, /* has the assignee seen this yet? */ description text NOT NULL, + opened varchar(64) NOT NULL DEFAULT '', authored varchar(64) NOT NULL DEFAULT '', + closed varchar(64) NOT NULL DEFAULT '', due varchar(64) NOT NULL DEFAULT '', tags text NOT NULL, -- cgit v1.2.3