/**
  * Send the password recovery email
  *
  * @todo Set email language according to the account preferences
  *
  * @param string email address
  * @return int Number of emails sent
  */
 function sendRecoveryEmail($email)
 {
     $aConf =& $GLOBALS['_MAX']['CONF'];
     $aPref = $GLOBALS['_MAX']['PREF'];
     $aUsers = $this->_dal->searchMatchingUsers($email);
     $aEmails = array();
     foreach ($aUsers as $u) {
         $aEmails[$u['email_address']][] = $u;
     }
     $sent = 0;
     foreach ($aEmails as $email => $aUsers) {
         $text = '';
         foreach ($aUsers as $u) {
             $recoveryId = $this->_dal->generateRecoveryId($u['user_id']);
             $header = $GLOBALS['strUser'] . " {$u['contact_name']}";
             $text .= $header . "\n" . str_repeat('-', strlen($header)) . "\n";
             $text .= $GLOBALS['strUsername'] . ": {$u['username']}\n";
             $text .= $GLOBALS['strPwdRecResetLink'] . ": ";
             $text .= Max::constructURL(MAX_URL_ADMIN, "password-recovery.php?id={$recoveryId}") . "\n\n";
         }
         // Hack
         $aConf['email']['admin_name'] = $aPref['admin_fullname'];
         $aConf['email']['admin'] = $aPref['admin_email'];
         $oEmail = new OA_Email();
         $oEmail->sendMail(sprintf($GLOBALS['strPwdRecEmailPwdRecovery'], $aPref['name']), $text, $email, $u['username']);
         $sent++;
     }
     return $sent;
 }
Esempio n. 2
0
 /**
  * A method to send the "midnight" reports during maintenance - that
  * is, the delivery information report, showing what the campaign(s)
  * have delivered since the last time the report was sendt.
  *
  * @access private
  */
 function _runReports()
 {
     OA::debug('  Starting to send advertiser "campaign delivery" reports.', PEAR_LOG_DEBUG);
     // Get all advertisers where the advertiser preference is to send reports
     OA::debug('   - Getting details of advertisers that require reports to be sent.', PEAR_LOG_DEBUG);
     $doClients = OA_Dal::factoryDO('clients');
     $doClients->report = 't';
     $doClients->find();
     while ($doClients->fetch()) {
         $aAdvertiser = $doClients->toArray();
         // Don't email report by default
         $sendReport = false;
         // Has the report interval date been passed?
         if (empty($aAdvertiser['reportlastdate'])) {
             $sendReport = true;
             $oReportLastDate = null;
         } else {
             $oNowDate = new Date();
             $oReportLastDate = new Date($aAdvertiser['reportlastdate']);
             $oSpan = new Date_Span();
             $oSpan->setFromDateDiff($oReportLastDate, $oNowDate);
             $daysSinceLastReport = (int) floor($oSpan->toDays());
             if ($daysSinceLastReport >= $aAdvertiser['reportinterval']) {
                 $sendReport = true;
             }
         }
         if ($sendReport) {
             // Send the advertiser's campaign delivery report
             $oEmail = new OA_Email();
             $oEmail->sendCampaignDeliveryEmail($aAdvertiser, $oReportLastDate);
         }
     }
     OA::debug('  Finished sending advertiser "campaign delivery" reports.', PEAR_LOG_DEBUG);
 }