Modified: pear2/BugManager/trunk/src/BugManager/Category/BaseAbstract.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Category/BaseAbstract.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Category/BaseAbstract.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -57,12 +57,15 @@ } } - function validateContext($contextname, $value, BugManager\Issue $bug) + function validateContext($contextname, $value, BugManager\Issue $bug, $multiple) { $ret = $this->listValidContextValues($contextname, $bug); if (true === $ret) { return true; } + if ($multiple && is_array($value)) { + return !count(array_diff($value, $ret)); + } return in_array($value, $ret); } Modified: pear2/BugManager/trunk/src/BugManager/Category/Pear2Package.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Category/Pear2Package.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Category/Pear2Package.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -28,30 +28,5 @@ class Pear2Package extends PearPackage { - /** - * @return array an array of values - */ - function listValidContextValues($contextname, BugManager\Issue $bug) - { - if ($contextname == 'phpversion' || $contextname == 'operatingsystem') { - return parent::listValidContextValues($contextname, $bug); - } - if (BugManager\Main::site() == 'pear2') { - return $bug->issuemanager->listValidContextValues($bug, $contextname, 'pear2'); - } - // this bug context is from an external site, we have to retrieve the - // values using a web service - // TODO: implement the web service client/server :) - } - - function validateContext($contextname, $value, BugManager\Issue $bug) - { - if ($contextname == 'phpversion' || $contextname == 'operatingsystem') { - return parent::validateContext($contextname, $value, $bug); - } - if (BugManager\Main::site() == 'pear2') { - return $bug->issuemanager->validateContext($bug, $contextname, 'pear2', $value); - } - return parent::validateContext($contextname, $value, $bug); - } + protected $categoryname = 'pear2'; } Modified: pear2/BugManager/trunk/src/BugManager/Category/PearPackage.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Category/PearPackage.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Category/PearPackage.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -29,13 +29,14 @@ { protected $secondaryId = false; protected $secondarySite = false; + protected $categoryname = 'pear'; /** * @return array array of names of contexts supported by this category */ function getSupportedContexts() { - return array('phpversion', 'package', 'packageversion', 'operatingsystem'); + return array('phpversion', 'package', 'packageversion', 'operatingsystem', 'milestones'); } /** @@ -46,22 +47,22 @@ if ($contextname == 'phpversion' || $contextname == 'operatingsystem') { return parent::listValidContextValues($contextname, $bug); } - if (BugManager\Main::site() == 'pear') { - return $bug->issuemanager->listValidContextValues($bug, $contextname, 'pear'); + if (BugManager\Main::site() == $this->categoryname) { + return $bug->issuemanager->listValidContextValues($bug, $contextname, $this->categoryname); } // this bug context is from an external site, we have to retrieve the // values using a web service // TODO: implement the web service client/server :) } - function validateContext($contextname, $value, BugManager\Issue $bug) + function validateContext($contextname, $value, BugManager\Issue $bug, $multiple) { if ($contextname == 'phpversion' || $contextname == 'operatingsystem') { - return parent::validateContext($contextname, $value, $bug); + return parent::validateContext($contextname, $value, $bug, $multiple); } - if (BugManager\Main::site() == 'pear') { - return $bug->issuemanager->validateContext($bug, $contextname, 'pear', $value); + if (BugManager\Main::site() == $this->categoryname) { + return $bug->issuemanager->validateContext($bug, $contextname, $this->categoryname, $value, $multiple); } - return parent::validateContext($contextname, $value, $bug); + return parent::validateContext($contextname, $value, $bug, $multiple); } } Modified: pear2/BugManager/trunk/src/BugManager/Category/PeclPackage.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Category/PeclPackage.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Category/PeclPackage.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -27,30 +27,5 @@ use pear2\BugManager; class PeclPackage extends PearPackage { - /** - * @return array an array of values - */ - function listValidContextValues($contextname, BugManager\Issue $bug) - { - if ($contextname == 'phpversion' || $contextname == 'operatingsystem') { - return parent::listValidContextValues($contextname, $bug, $manager); - } - if (BugManager\Main::site() == 'pecl') { - return $bug->issuemanager->listValidContextValues($bug, $contextname); - } - // this bug context is from an external site, we have to retrieve the - // values using a web service - // TODO: implement the web service client/server :) - } - - function validateContext($contextname, $value, BugManager\Issue $bug) - { - if ($contextname == 'phpversion' || $contextname == 'operatingsystem') { - return parent::validateContext($contextname, $value, $bug); - } - if (BugManager\Main::site() == 'pecl') { - return $bug->issuemanager->validateContext($bug, $contextname, 'pecl', $value); - } - return parent::validateContext($contextname, $value, $bug); - } + protected $categoryname = 'pecl'; } Modified: pear2/BugManager/trunk/src/BugManager/Category/PhpComponent.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Category/PhpComponent.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Category/PhpComponent.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -35,7 +35,7 @@ */ function getSupportedContexts() { - return array('phpversion', 'bugtype', 'operatingsystem'); + return array('phpversion', 'bugtype', 'operatingsystem', 'milestones'); } /** Modified: pear2/BugManager/trunk/src/BugManager/Category.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Category.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Category.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -73,9 +73,9 @@ return $context; } - function validateContext(Issue $bug, $name, $source, $value) + function validateContext(Issue $bug, $name, $source, $value, $multiple) { - return $this->locateSource($source)->validateContext($name, $value, $bug); + return $this->locateSource($source)->validateContext($name, $value, $bug, $multiple); } function listValidContextValues(Issue $bug, $name, $source) Modified: pear2/BugManager/trunk/src/BugManager/CategoryInterface.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/CategoryInterface.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/CategoryInterface.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -37,7 +37,7 @@ /** * @return bool */ - function validateContext($contextname, $value, Issue $bug); + function validateContext($contextname, $value, Issue $bug, $multiple); /** * @param int the id of the bug on the secondary site * @param string either pear, pear2, pecl or php Modified: pear2/BugManager/trunk/src/BugManager/Context.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Context.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Context.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -39,25 +39,47 @@ * @var pear2\BugManager\ContextContainer */ protected $container; + /** + * If true, this context can contain multiple values, and is stored as an array + * @var bool + */ + protected $multiple; - function __construct($name, Issue $parent, $source) + function __construct($name, Issue $parent, $source, $multiple = false) { $this->parent = $parent; $this->name = $name; $this->source = $source; + $this->multiple = $multiple; + if ($this->multiple) { + $this->value = array(); + } } function setValue($value) { + if ($this->multiple && !is_array($value)) { + if ($this->value = array($value)) { + return; + } + } if ($this->value === $value) { return; } - if ($this->parent->validateContext($this->name, $this->source, $value)) { + if ($this->parent->validateContext($this->name, $this->source, $value, $this->multiple)) { if ($this->container) { $this->container->modified(); } + if ($this->multiple && !is_array($value)) { + $val = $this->value; + $val[] = $value; + $value = $val; + } $this->value = $value; } else { + if (is_array($value)) { + $value = '(' . implode(',', $value) . ')'; + } throw new UnexpectedValueException('Invalid value ' . $value . ' for ' . 'context ' . $this->name . ' from ' . 'source ' . $this->source); @@ -86,6 +108,13 @@ function equals(Context $c) { + if ($this->multiple) { + $val = $this->value; + $check = $c->value(); + sort($val); + sort($check); + return $val == $check; + } return $this->value == $c->value(); } Modified: pear2/BugManager/trunk/src/BugManager/ContextContainer.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/ContextContainer.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/ContextContainer.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -42,13 +42,17 @@ */ function setValues(array $values) { - $order = array('phpversion', 'packagename', 'packageversion', 'operatingsystem'); + $order = array('phpversion' => false, + 'packagename' => false, + 'packageversion' => false, + 'operatingsystem' => false, + 'milestones' => true); $contexts = array(); - foreach ($order as $key) { + foreach ($order as $key => $multiple) { if (!isset($values[$key])) { continue; } - $contexts[$key] = new Context($key, $this->parent, $values[$key]['source']); + $contexts[$key] = new Context($key, $this->parent, $values[$key]['source'], $multiple); $contexts[$key]->setContainer($this); $contexts[$key]->setValue($values[$key]['value']); $this->exchangeArray($contexts); // this allows instant access to contexts from other contexts @@ -65,7 +69,8 @@ $this->modified(); } } else { - $new = new Context($name, $this->parent, $source); + $multiple = ($name == 'milestones'); + $new = new Context($name, $this->parent, $source, $multiple); $new->setContainer($this); } $new->setvalue($value); Modified: pear2/BugManager/trunk/src/BugManager/Issue.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Issue.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/Issue.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -42,7 +42,6 @@ 'category' => null, // Category object 'context' => array(), // ContextContainer object 'status' => null, - 'roadmap' => array(), // roadmap versions assigned to this bug 'comments' => array(), // array of Comment objects ); /** @@ -57,7 +56,6 @@ 'category' => null, // Category object 'context' => array(), // ContextContainer object 'status' => null, - 'roadmap' => array(), // roadmap versions assigned to this bug 'comments' => array(), // array of Comment objects ); @@ -263,9 +261,9 @@ return $this->issuemanager->search($this, $pagelength, $pagenumber); } - function validateContext($name, $source, $value) + function validateContext($name, $source, $value, $multiple = false) { - return $this->category->validateContext($this, $name, $source, $value); + return $this->category->validateContext($this, $name, $source, $value, $multiple); } function listValidContextValues($name, $source) @@ -273,11 +271,6 @@ return $this->category->listValidContextValues($this, $name, $source); } - function addRoadmapVersion($version) - { - $this->newvalues['roadmap'][] = $version; - } - function addComment(Comment $comment) { $comments = $this->comments; Modified: pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -94,12 +94,6 @@ return $ret; } - function getRoadmapInsertSql($id) - { - // TODO: roadmap/attachments/external bug info - return ''; - } - function getAttachmentInsertSql($id) { // TODO: roadmap/attachments/external bug info Modified: pear2/BugManager/trunk/src/BugManager/IssueManager/Mysql.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/IssueManager/Mysql.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/IssueManager/Mysql.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -113,7 +113,7 @@ } if ($result->num_rows) { while ($roadmap = $result->fetch_assoc()) { - $bug->addRoadmapVersion($roadmap['roadmap_version']); + $bug->context['milestones'] = $roadmap['roadmap_version']; } } $result->close(); @@ -196,10 +196,6 @@ $comment->id = $this->mysqli->insert_id(); } } - $sql = $decorator->getRoadmapInsertSql($id); - if ($sql) { - $this->mysqli->query($sql); - } $sql = $decorator->getAttachmentInsertSql($id); if ($sql) { $this->mysqli->query($sql); @@ -240,27 +236,35 @@ } /** - * @return array array of names of contexts supported by this bug type - */ - function getSupportedContexts(Issue $bug) - { - - } - - /** - * @return pear2\BugManager\Context - */ - function getContext(Issue $bug, $contextname, $source = null) - { - - } - - /** * @return bool */ - function validateContext(Issue $bug, $contextname, $source, $value) + function validateContext(Issue $bug, $contextname, $source, $value, $multiple) { - if ($source == 'pear' || $source == 'pecl') { + if ($multiple) { + if (is_array($value)) { + foreach ($value as $val) { + if (!$this->validateContext($bug, $contextname, $source, $val, false)) { + return false; + } + } + return true; + } + } + if ($contextname == 'milestones') { + if ($source == 'pear' || $source == 'pecl' || $source == 'pear2') { + $sql = 'SELECT COUNT(*) as count + FROM bugmanager_roadmap r + WHERE + r.package="' . $this->esc($bug->context['packagename']->value()) . '" + AND roadmap_version="' . $this->esc($value) . '"'; + } elseif ($source == 'php') { + $sql = 'SELECT COUNT(*) as count + FROM bugmanager_roadmap r + WHERE + r.package="PHP" + AND roadmap_version="' . $this->esc($value) . '"'; + } + } elseif ($source == 'pear' || $source == 'pecl') { if ($contextname == 'packagename') { $sql = 'SELECT COUNT(*) as count FROM packages WHERE name="' . $this->esc($value) . '"'; @@ -271,6 +275,7 @@ r.version="' . $this->esc($value) . '"'; } } else { + // have to make this better $sql = 'SELECT 1 as count'; } $result = $this->mysqli->query($sql); @@ -286,7 +291,17 @@ if (null === $source) { $source = Bugmanager\Main::site(); } - if ($source == 'pear' || $source == 'pecl') { + if ($contextname == 'milestones') { + if ($source == 'pear' || $source == 'pecl' || $source == 'pear2') { + $sql = 'SELECT roadmap_version as val + FROM bugmanager_roadmap r + WHERE + r.package="' . $this->esc($bug->context['packagename']->value()) . '" + ORDER BY releasedate DESC'; + } elseif ($source == 'php') { + return array('PHP'); + } + } elseif ($source == 'pear' || $source == 'pecl') { if ($contextname == 'packagename') { $sql = 'SELECT name as val FROM packages ORDER BY name'; } elseif ($contextname == 'packageversion') { Modified: pear2/BugManager/trunk/src/BugManager/IssueManagerInterface.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/IssueManagerInterface.php 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/src/BugManager/IssueManagerInterface.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -53,13 +53,9 @@ */ function delete(Issue $bug); /** - * @return pear2\BugManager\Context - */ - function getContext(Issue $bug, $contextname, $source = null); - /** * @return bool */ - function validateContext(Issue $bug, $contextname, $source, $value); + function validateContext(Issue $bug, $contextname, $source, $value, $multiple); /** * @return array */ Added: pear2/BugManager/trunk/src/BugManager/Milestone.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/Milestone.php (rev 0) +++ pear2/BugManager/trunk/src/BugManager/Milestone.php 2009-08-12 20:00:55 UTC (rev 287176) @@ -0,0 +1,76 @@ + + * @copyright 2009 Gregory Beaver + * @license http://www.opensource.org/licenses/bsd-license.php New BSD License + * @version SVN: $Id$ + * @link http://svn.php.net/repository/pear2/BugManager + */ + +/** + * Represents a Milestone in a roadmap + * + * @category Bugs + * @package PEAR2_BugManager + * @author Gregory Beaver + * @copyright 2009 Gregory Beaver + * @license http://www.opensource.org/licenses/bsd-license.php New BSD License + * @link http://svn.php.net/repository/pear2/BugManager + */ +namespace pear2\BugManager; +class Milestone +{ + protected $info = array( + 'version' => null, + 'package' => null, + 'releasedate' => null, + 'description' => null, + 'released' => null, + ); + protected $manager; + protected $issues = array(); + + function __construct(IssueManagerInterface $manager) + { + $this->manager = $manager; + } + + /** + * set the issues that are attached to this milestone + */ + function setIssues(array $issues) + { + + } + + /** + * @return array an array of id numbers of issues that can be + * attached to this milestone + */ + function listAvailableIssues() + { + + } + + /** + * Mark the milestone as having been released + */ + function release() + { + + } + + /** + * Remove the milestone and detach all issues + */ + function delete() + { + + } +} Modified: pear2/BugManager/trunk/tests/Issue/setup.php.inc =================================================================== --- pear2/BugManager/trunk/tests/Issue/setup.php.inc 2009-08-12 19:40:15 UTC (rev 287175) +++ pear2/BugManager/trunk/tests/Issue/setup.php.inc 2009-08-12 20:00:55 UTC (rev 287176) @@ -41,13 +41,9 @@ */ function history($id, $start, $limit){} /** - * @return pear2\BugManager\Context - */ - function getContext(Issue $bug, $contextname, $source = null){} - /** * @return bool */ - function validateContext(Issue $bug, $contextname, $source, $value){} + function validateContext(Issue $bug, $contextname, $source, $value, $multiple){} /** * @return array */