public function log(PostmanLogger $log, $desc)
 {
     $message = $desc . ' email=' . $this->getEmail();
     if (!empty($this->name)) {
         $message .= ' name=' . $this->getName();
     }
     $log->debug($message);
 }
 public static function createConfig(PostmanTransport $transport)
 {
     // create Logger
     $logger = new PostmanLogger("PostmanBasicAuthConfigurationFactory");
     // retrieve the hostname and port form the transport
     $hostname = $transport->getHostname();
     $port = $transport->getPort();
     $securityType = $transport->getSecurityType();
     $authType = $transport->getAuthenticationType();
     $username = $transport->getCredentialsId();
     $password = $transport->getCredentialsSecret();
     // create the Configuration structure for Zend_Mail
     $config = array('port' => $port);
     $logger->debug(sprintf('Using %s:%s ', $hostname, $port));
     if ($securityType != PostmanOptions::SECURITY_TYPE_NONE) {
         $config['ssl'] = $securityType;
         $logger->debug('Using encryption ' . $securityType);
     } else {
         $logger->debug('Using no encryption');
     }
     if ($authType != PostmanOptions::AUTHENTICATION_TYPE_NONE) {
         $config['auth'] = $authType;
         $config['username'] = $username;
         $config['password'] = $password;
         $logger->debug(sprintf('Using auth %s with username %s and password %s', $authType, $username, PostmanUtils::obfuscatePassword($password)));
     } else {
         $logger->debug('Using no authentication');
     }
     // return the Configuration structure
     return $config;
 }
Esempio n. 3
0
function postman_google_api_php_client_autoload($className)
{
    $logger = new PostmanLogger('postman_google_api_php_client_autoload');
    $logger->trace('Autoloading ' . $className);
    $classPath = explode('_', $className);
    // @jason: make sure the first segment of the classname is 'Postman'
    if (empty($classPath[0]) || empty($classPath[1])) {
        return;
    }
    if ($classPath[0] != 'Postman' && $classPath[1] != 'Google') {
        return;
    } else {
        // @jason: get rid of the first segment of the classname
        $classPath = array_slice($classPath, 1);
    }
    if (count($classPath) > 3) {
        // Maximum class file path depth in this project is 3.
        $classPath = array_slice($classPath, 1, 4);
    }
    $filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php';
    if (file_exists($filePath)) {
        require_once $filePath;
    }
}
Esempio n. 4
0
 /**
  * PHP version less than 5.3 don't have str_getcsv natively.
  *
  * @param unknown $string
  * @return multitype:
  */
 function str_getcsv($string)
 {
     $logger = new PostmanLogger('postman-common-functions');
     $logger->debug('Using custom str_getcsv');
     return PostmanUtils::postman_strgetcsv_impl($string);
 }
 /**
  * Create a custom post type
  * Callback function - must be public scope
  *
  * register_post_type should only be invoked through the 'init' action.
  * It will not work if called before 'init', and aspects of the newly
  * created or modified post type will work incorrectly if called later.
  *
  * https://codex.wordpress.org/Function_Reference/register_post_type
  */
 public static function create_post_type()
 {
     register_post_type(self::POSTMAN_CUSTOM_POST_TYPE_SLUG, array('labels' => array('name' => _x('Sent Emails', 'The group of Emails that have been delivered', Postman::TEXT_DOMAIN), 'singular_name' => _x('Sent Email', 'An Email that has been delivered', Postman::TEXT_DOMAIN)), 'capability_type' => '', 'capabilities' => array()));
     $logger = new PostmanLogger('PostmanEmailLogPostType');
     $logger->trace('Created post type: ' . self::POSTMAN_CUSTOM_POST_TYPE_SLUG);
 }
Esempio n. 6
0
 /**
  *
  * @param unknown $data        	
  */
 public function import($data)
 {
     if (PostmanPreRequisitesCheck::checkZlibEncode()) {
         $logger = new PostmanLogger(get_class($this));
         $logger->debug('Importing Settings');
         $base64 = $data;
         $logger->trace($base64);
         $gz = base64_decode($base64);
         $logger->trace($gz);
         $json = @gzuncompress($gz);
         $logger->trace($json);
         if (!empty($json)) {
             $data = json_decode($json, true);
             $logger->trace($data);
             // overwrite the current version with the version from the imported options
             // this way database upgrading can occur
             $postmanState = get_option('postman_state');
             $postmanState['version'] = $data['version'];
             $logger->trace(sprintf('Setting Postman version to %s', $postmanState['version']));
             assert($postmanState['version'] == $data['version']);
             update_option('postman_state', $postmanState);
             $this->options = $data;
             $logger->info('Imported data');
             $this->save();
             return true;
         } else {
             $logger->error('Could not import data - data error');
             return false;
         }
     }
 }
 /**
  * If the host port is a possible configuration option, recommend it
  *
  * $hostData includes ['host'] and ['port']
  *
  * response should include ['success'], ['message'], ['priority']
  *
  * @param unknown $hostData        	
  */
 public function getRecommendation($hostData, $userAuthOverride, $originalSmtpServer)
 {
     //
     $priority = -1;
     $winningRecommendation = null;
     $logger = new PostmanLogger(get_class($this));
     $scrubbedUserAuthOverride = $this->scrubUserOverride($hostData, $userAuthOverride);
     foreach ($this->getTransports() as $transport) {
         $recommendation = $transport->getConfigurationBid($hostData, $scrubbedUserAuthOverride, $originalSmtpServer);
         $logger->debug(sprintf('Transport %s bid %s', $transport->getName(), $recommendation['priority']));
         if ($recommendation['priority'] > $priority) {
             $priority = $recommendation['priority'];
             $winningRecommendation = $recommendation;
         }
     }
     return $winningRecommendation;
 }