/** * CompleteCondition constructor. */ public function __construct() { /** * assume everything is NOT ok */ $isOk = false; /** * support variable number of arguments for future use */ $args = func_get_args(); switch (func_num_args()) { case 0: /** * init the time to the maximum possible * int for this php build, should be enough * to always consider the condition not satisfied */ $this->_param = PHP_INT_MAX; $isOk = true; break; case 1: /** * args[0] is the time the user wants to set */ $isOk = $this->setIntParam($args[0]); break; default: /** * by default, some error has occoured */ $isOk = false; break; } /** * handle the error some way... */ if (!$isOk) { /** * wrong number of arguments, let's take some action: * first: log the error. this shall go to log/trace.log file */ ADAFileLogger::log(__CLASS__ . '::' . __METHOD__ . ' WRONG NUMBER OR TYPE OF PARAMETERS'); /** * third: raise an ADA_Error if wrong number of arguments * see config_errors.inc.php line 167 and following. * depending on the erorr phase / severity something will happen... */ new ADA_Error(NULL, NULL, __METHOD__, AMA_ERR_WRONG_ARGUMENTS, ADA_ERROR_SEVERITY_NONE); /** * third throw an exception to be catched by the caller */ throw new Exception('Fatal Error: could not instantiate ' . __CLASS__, AMA_ERR_WRONG_ARGUMENTS); } }
/** * logs a message in the log file defined in the logFile private property. * * @param string $text the message to be logged * * @return unknown_type * * @access private */ private function _logMessage($text) { // the file must exists, otherwise logger won't log if (!is_file($this->_logFile)) { touch($this->_logFile); } ADAFileLogger::log($text, $this->_logFile); }
/** * handles logging of db messages * * @param $text the message to log * @return void */ public static function log_db($text) { if (ADA_LOGGING_LEVEL & ADA_LOG_DB) { switch (ADA_LOG_DB_SELECTED_LOGGER) { case ADA_LOGGER_SCREEN_LOG: ADAScreenLogger::log($text); break; case ADA_LOGGER_FILE_LOG: ADAFileLogger::log($text, ADA_LOG_DB_FILE_LOG_OUTPUT_FILE); break; case ADA_LOGGER_NULL_LOG: default: } } }
$userFullName = ''; if (!AMA_DB::isError($userInfo)) { // performs user substitutions $HTMLText = str_replace(array("{name}", "{lastname}", "{e-mail}"), array($userInfo['nome'], $userInfo['cognome'], $userInfo['email']), $HTMLModelText); $PLAINText = str_replace(array("{name}", "{lastname}", "{e-mail}"), array($userInfo['nome'], $userInfo['cognome'], $userInfo['email']), $PLAINModelText); $userFullName = ucwords(strtolower($userInfo['nome'] . ' ' . $userInfo['cognome'])); } else { $HTMLText = $HTMLModelText; $PLAINText = $PLAINModelText; $userFullName = ''; } // $recipient[1] is the email in the current run loop $phpmailer->AddAddress($recipient[1], $userFullName); $phpmailer->Body = $HTMLText; $phpmailer->AltBody = $PLAINText; $phpmailer->Send(); $phpmailer->ClearAllRecipients(); if ($num < count($recipients) - 1) { ADAFileLogger::log('goin to sleep...', $logFile); usleep($sleepTime); ADAFileLogger::log('...got woken up', $logFile); } } $res = $dh->set_history_status($history_id, MODULES_NEWSLETTER_HISTORY_STATUS_SENT); if (AMA_DB::isError($res)) { ADAFileLogger::log(print_r($res, true), $logFile); } ADAFileLogger::log('Done... OK!', $logFile); } } }