QA_Peardoc_Coverage
[ class tree: QA_Peardoc_Coverage ] [ index: QA_Peardoc_Coverage ] [ all elements ]

Source for file sendMails.php

Documentation is available at sendMails.php

  1. <?php
  2. /**
  3. *   Send mails to the devs telling them that their packages
  4. *   miss end user documentation.
  5. */
  6. require_once 'PEAR.php';
  7. require_once 'Mail.php';
  8. require_once 'Console/Getargs.php';
  9. require_once 'Console/ProgressBar.php';
  10.  
  11. $config = array(
  12.     'server' => array(
  13.             'min' => 1,
  14.             'max' => 1,
  15.             'desc' => 'SMTP server'),
  16.     'port' => array(
  17.             'min' => 1,
  18.             'max' => 1,
  19.             'desc' => 'SMTP server port',
  20.             'default' => 25),
  21.     'user' => array(
  22.             'min' => 1,
  23.             'max' => 1,
  24.             'desc' => 'SMTP user'),
  25.     'password' => array(
  26.             'min' => 1,
  27.             'max' => 1,
  28.             'desc' => 'SMTP password'),
  29.     'debug' => array('short' => 'd',
  30.             'max' => 0,
  31.             'desc' => 'Switch to debug mode.'),
  32.     'pretend' => array('short' => 'p',
  33.             'max' => 0,
  34.             'desc' => 'Display what would be done, but do not send any mails.'),
  35. );
  36.  
  37. $args = Console_Getargs::factory($config);
  38.  
  39. if (PEAR::isError($args)) {
  40.     if ($args->getCode(=== CONSOLE_GETARGS_ERROR_USER{
  41.         echo Console_Getargs::getHelp($confignull$args->getMessage())."\n";
  42.     else if ($args->getCode(=== CONSOLE_GETARGS_HELP{
  43.         echo Console_Getargs::getHelp($config)."\n";
  44.     }
  45.     exit;
  46. }
  47.  
  48. $bDebug         $args->isDefined('d');
  49. $bPretend       $args->isDefined('p');
  50. $arMailParams = array(
  51.     'host'      => $args->getValue('server'),
  52.     'port'      => $args->getValue('port'),
  53.     'username'  => $args->getValue('user'),
  54.     'password'  => $args->getValue('password'),
  55.     'auth'      => true,
  56.     'persist'   => true
  57. );
  58.  
  59.  
  60.  
  61. $strMessage = <<<EOD
  62. Dear PEAR developer,
  63.  
  64. Some of your packages in PEAR do not have end-user documentation
  65. in the official PEAR manual. Since the best package is useless
  66. without proper documentation, we ask you to write that for
  67. the packages not having any. And do remember that the auto-generated
  68. API-documentation does not replace end-user documentation as found
  69. in the manual. Use case and examples as well as an introduction
  70. to the way the package works is invaluable to the user wishing to use it.
  71.  
  72. Your packages missing documentation:
  73. {PACKAGES}
  74.  
  75. If you have already written documentation located on an
  76. external server, plase consider transferring it into the PEAR manual.
  77. If that is not possible we ask you to create a link
  78. in the PEAR manual pointing to it.
  79.  
  80. In case you are not a developer of one of the mentioned packages,
  81. the information in the package.xml file is wrong.
  82. Ask the lead of that package to correct the data.
  83.  
  84.  
  85. Regards,
  86. The PEAR QA team.
  87. EOD;
  88.  
  89. if (!file_exists('missingdocs.serialized')) {
  90.     echo <<<EOD
  91. Please run examples/genMissingDocsPerDeveloper.php
  92. and save the output into a file called
  93. "missingdocs.serialized"
  94. EOD;
  95.     exit(1);
  96. }
  97.  
  98. $arData unserialize(file_get_contents('missingdocs.serialized'));
  99.  
  100. if (count($arData== 0{
  101.     echo "All packages seem to be documented. Nothing to do here.\n";
  102.     exit(0);
  103. }
  104.  
  105. echo "Sending mails\n";
  106. $bar = new Console_ProgressBar(' %fraction% [%bar%] ''=>'' '80count($arData));
  107. $mail = Mail::factory('smtp'$arMailParams);
  108. if (PEAR::isError($mail)) {
  109.     echo $mail->getMessage("\n";
  110.     exit(2);
  111. }
  112.  
  113. $nCurrentMail = 0;
  114.  
  115. foreach ($arData as $strDevEmail => $arUndocumented{
  116.     if ($strDevEmail == '???' || $strDevEmail == ''{
  117.         continue;
  118.     }
  119.  
  120.     $strPackages implode(', '$arUndocumented);
  121.     $strMailText str_replace('{PACKAGES}'$strPackages$strMessage);
  122.  
  123.     if ($bDebug{
  124.         echo 'Mail to ' $strDevEmail ' with text:' "\n" $strMailText "\n\n";
  125.     else {
  126.         $bar->update(++$nCurrentMail);
  127.     }
  128.     if (!$bPretend{
  129.         $ret $mail->send(
  130.             $strDevEmail,
  131.             array(
  132.                 'From'          => 'pear-qa@lists.php.net',
  133.                 'To'            => $strDevEmail,
  134.                 'Reply-To'      => 'pear-dev@lists.php.net',
  135.                 'User-Agent'    => 'QA_Peardoc_Coverage',
  136.                 'Subject'       => '[PEAR-QA] Missing package documentation reminder'
  137.             ),
  138.             $strMailText
  139.         );
  140.         if (PEAR::isError($ret)) {
  141.             echo 'Could not send mail!' "\n";
  142.             echo $ret->getMessage("\n";
  143.             exit(3);
  144.         }
  145.     }
  146. }
  147.  
  148. echo "Done sending mails\n";
  149. ?>

Documentation generated on Mon, 11 Mar 2019 15:10:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.