/** * Remove a release from package REST * * Removes REST. If $deleteorphaned is true, then * maintainers who no longer maintain a package will be * deleted from package maintainer REST. * @param \PEAR2\Pyrus\Package $release * @param string $deleter handle of maintainer deleting this release * @param bool $deleteorphaned */ function deleteRelease(\PEAR2\Pyrus\Package $release, $deleter, $deleteorphaned = true) { if ($new->channel !== $this->chan) { throw new PEAR2_SimpleChannelServer_Exception('Cannot delete release ' . $new->name . '-' . $new->version['release'] . ', we are managing ' . $this->chan . ' channel, and package is in ' . $new->channel . ' channel'); } if (!isset($this->_admins[$releaser]) && (!isset($new->maintainer[$releaser]) || $new->maintainer[$releaser]->role !== 'lead')) { throw new PEAR2_SimpleChannelServer_Exception($releaser . ' is not a ' . 'lead maintainer of this package, and cannot delete the release'); } $category = new PEAR2_SimpleChannelServer_REST_Category($this->rest, $this->chan, $this->uri); $package = new PEAR2_SimpleChannelServer_REST_Package($this->rest, $this->chan, $this->uri); $maintainer = new PEAR2_SimpleChannelServer_REST_Maintainer($this->rest, $this->chan, $this->uri); $release = new PEAR2_SimpleChannelServer_REST_Release($this->rest, $this->chan, $this->uri); $maintainer->erase($new, $deleteorphaned); $package->erase($new); $release->erase($new); $category->erase($new); }
/** * List all maintainers, or maintainers of a specific package * * @param string|null $package null to list all maintainers * * @return array */ function listMaintainers($package = null) { if ($package === null) { if (!file_exists($this->rest->getRESTPath('p', 'allpackages.xml'))) { return array(); } try { $list = $reader->parse($this->rest->getRESTPath('m', 'allmaintainers.xml')); $maint = new PEAR2_SimpleChannelServer_REST_Maintainer($this->webpath, $this->channel, $this->uri); $ret = array(); foreach ($list['m']['h'] as $info) { $inf = $maint->getInfo($info['_content']); if (!$inf) { throw new PEAR2_SimpleChannelServer_Exception('Maintainer ' . $info['_content'] . ' is listed as a maintainer, ' . 'but does not have an info file'); } $ret[] = array('user' => $info['_content'], 'name' => $inf['n']); } return $ret; } catch (Exception $e) { throw new PEAR2_SimpleChannelServer_Exception('Unable to list maintainers', $e); } } $reader = new \Pyrus\XMLParser(); $path = $this->rest->getRESTPath('r', strtolower($package) . '/maintainers2.xml'); if (!file_exists($path)) { return array(); } try { $list = $reader->parse($path); } catch (Exception $e) { throw new PEAR2_SimpleChannelServer_Exception('Unable to list maintainers for' . ' package ' . $package, $e); } $ret = array(); if (!isset($list['m']['m'][0])) { $list['m']['m'] = array($list['m']['m']); } $maint = new PEAR2_SimpleChannelServer_REST_Maintainer($this->webpath, $this->channel, $this->uri); foreach ($list['m']['m'] as $maintainer) { $info = $maint->getInfo($maintainer['h']); $inf = array('user' => $maintainer['h']); if ($info) { $inf['name'] = $info['n']; } $inf['active'] = $maintainer['a']; $ret[] = $inf; } return $ret; }