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 ($stage->objtype != "stage") return; if (!($next = $stage->getNext())) $this->close(); else $this->setParent($next); } /* * Mark this issue as completed and closed. */ public function close() : void { $pad = $this->getParent()->getParent(); if ($pad) $this->setParent($pad); } } ?>