Example #1
0
 /**
  * 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 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 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 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 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 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;
 }
Example #2
0
 function pyrusAddMaintainer($frontend, $args)
 {
     $this->getSCS();
     $maintainer = new REST\Maintainer($this->dir . '/rest', $this->channel->name);
     if (isset($args['uri'])) {
         $uri = $args['uri'];
     } else {
         $uri = null;
     }
     $maintainer->saveInfo($args['handle'], $args['name'], $uri);
     $maintainer->saveAll();
     echo "Added maintainer ", $args['handle'], "\n";
 }