PEAR logo

PEAR_PackageFileManager : The Definitive Guide



Change full name, email address, role or status of a maintainer

Once again, if you think this function is useless, you may consider that the package script generator could use data coming from another source (such as a database, a flat file, ...) rather than just hard-coded.

Checking of duplicates is performed by usage of updateMaintainer(), and even allow adding a new user if he did not exists.

[Important] Important
This feature is only available for PEAR_PackageFileManager 1.6.0 or better. To do the same thing, by programming, with package.xml version 1.0, you should set options with an empty "maintainers" array first, before apply the addMaintainer() method.

To produce a package.xml version 1.0

  1. <?php
  2. require_once 'PEAR/PackageFileManager.php';
  3. require_once 'MDB2.php';
  4.  
  5. PEAR::setErrorHandling(PEAR_ERROR_DIE);
  6.  
  7. // ...
  8.  
  9. $p1 = new PEAR_PackageFileManager();
  10. $p1->setOptions(array(
  11.     'maintainers' => array(),
  12.     // any other option ...
  13. ));
  14. //...
  15. $res =& $mdb2->query('SELECT * FROM maintainers');
  16.  
  17. while (($m = $res->fetchRow())) {
  18.  
  19.     $p1->addMaintainer($m->handle, $m->newrole, $m->newname, $m->newemail);
  20. }
  21. ?>

To produce a package.xml version 2.0

  1. <?php
  2. require_once 'PEAR/PackageFileManager2.php';
  3. require_once 'MDB2.php';
  4.  
  5. PEAR::setErrorHandling(PEAR_ERROR_DIE);
  6.  
  7. // ...
  8.  
  9. $packagefile = 'c:/php/pear/HTML_AJAX/package2.xml';
  10. // $options = array();
  11.  
  12. $p2 = &PEAR_PackageFileManager2::importOptions($packagefile, $options);
  13. //...
  14. $res =& $mdb2->query('SELECT * FROM maintainers');
  15.  
  16. while (($m = $res->fetchRow())) {
  17.  
  18.     if ($m->exists) {
  19.         $p2->updateMaintainer($m->newrole, $m->handle, $m->newname, $m->newemail, $m->newstatus);
  20.     } else {
  21.         $p2->deleteMaintainer($m->handle);
  22.     }
  23. }
  24. ?>
PEAR_PackageFileManager : The Definitive Guide v 1.6.0 : November 17, 2006