[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Net/SMS/ -> vodafoneitaly_smtp.php (source)

   1  <?php
   2  /**
   3   * Net_SMS_vodafoneitaly_smtp Class implements the SMTP API for accessing the
   4   * Vodafone Italy SMS gateway. Use of this gateway requires an email account
   5   * with Vodafone Italy (www.190.it).
   6   *
   7   * Copyright 2003-2006 Marko Djukic <marko@oblo.com>
   8   * Copyright 2003-2006 Matteo Zambelli <mmzambe@hotmail.com>
   9   *
  10   * See the enclosed file COPYING for license information (LGPL). If you did not
  11   * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  12   *
  13   * $Horde: framework/Net_SMS/SMS/vodafoneitaly_smtp.php,v 1.11.10.8 2006/01/01 21:28:29 jan Exp $
  14   *
  15   * @author Marko Djukic <marko@oblo.com>
  16   * @author Matteo Zambelli <mmzambe@hotmail.com>
  17   * @package Net_SMS
  18   */
  19  class Net_SMS_vodafoneitaly_smtp extends Net_SMS {
  20  
  21      /**
  22       * An array of capabilities, so that the driver can report which operations
  23       * it supports and which it doesn't. Possible values are:<pre>
  24       *   auth        - The gateway require authentication before sending;
  25       *   batch       - Batch sending is supported;
  26       *   multi       - Sending of messages to multiple recipients is supported;
  27       *   receive     - Whether this driver is capable of receiving SMS;
  28       *   credit      - Is use of the gateway based on credits;
  29       *   addressbook - Are gateway addressbooks supported;
  30       *   lists       - Gateway support for distribution lists.
  31       * </pre>
  32       *
  33       * @var array
  34       */
  35      var $capabilities = array('auth'        => false,
  36                                'batch'       => false,
  37                                'multi'       => false,
  38                                'receive'     => false,
  39                                'credit'      => false,
  40                                'addressbook' => false,
  41                                'lists'       => false);
  42  
  43      /**
  44       * This function does the actual sending of the message.
  45       *
  46       * @access private
  47       *
  48       * @param array $message  The array containing the message and its send
  49       *                        parameters.
  50       * @param string $to      The destination string.
  51       *
  52       * @return array  An array with the success status and additional
  53       *                information.
  54       */
  55      function _send(&$message, $to)
  56      {
  57          if (!@include_once 'Mail.php') {
  58              return PEAR::raiseError(_("Missing required PEAR package Mail."));
  59          }
  60          $mailer = Mail::factory('mail');
  61  
  62          /* Since this only works for Italian numbers, this is hardcoded. */
  63          if (preg_match('/^.*?<?(\+?39)?(\d{10})>?/', $to, $matches)) {
  64              $headers['From'] = $this->_params['user'];
  65              $to = $matches[2] . '@sms.vodafone.it';
  66              $result = $mailer->send($to, $headers, $message['text']);
  67              if (is_a($result, 'PEAR_Error')) {
  68                  return array(0, $result->getMessage());
  69              } else {
  70                  return array(1, null);
  71              }
  72          } else {
  73              return array(0, _("You need to provide an Italian phone number"));
  74          }
  75      }
  76  
  77      /**
  78       * Identifies this gateway driver and returns a brief description.
  79       *
  80       * @return array  Array of driver info.
  81       */
  82      function getInfo()
  83      {
  84          $info['name'] = _("Vodafone Italy via SMTP");
  85          $info['desc'] = _("This driver allows sending of messages via SMTP through the Vodafone Italy gateway, only to Vodafone numbers. It requires an email account with Vodafone Italy (http://www.190.it).");
  86  
  87          return $info;
  88      }
  89  
  90      /**
  91       * Returns the required parameters for this gateway driver.
  92       *
  93       * @return array  Array of required parameters.
  94       */
  95      function getParams()
  96      {
  97          $params = array();
  98          $params['user']       = array('label'  => _("Username"),
  99                                        'type'   => 'text');
 100  
 101          return $params;
 102      }
 103  
 104      /**
 105       * Returns the parameters that can be set as default for sending messages
 106       * using this gateway driver and displayed when sending messages.
 107       *
 108       * @return array  Array of parameters that can be set as default.
 109       */
 110      function getDefaultSendParams()
 111      {
 112          return array();
 113      }
 114  
 115      /**
 116       * Returns the parameters for sending messages using this gateway driver,
 117       * displayed when sending messages. These are filtered out using the
 118       * default values set up when creating the gateway.
 119       *
 120       * @return array  Array of required parameters.
 121       * @todo  Would be nice to use a time/date setup rather than minutes from
 122       *        now for the delivery time. Upload field for ringtones/logos?
 123       */
 124      function getSendParams($params)
 125      {
 126          return array();
 127      }
 128  
 129      /**
 130       * Returns a string representation of an error code.
 131       *
 132       * @param integer $error  The error code to look up.
 133       * @param string $text    An existing error text to use to raise a
 134       *                        PEAR Error.
 135       *
 136       * @return mixed  A textual message corresponding to the error code or a
 137       *                PEAR Error if passed an existing error text.
 138       *
 139       * @todo  Check which of these are actually required and trim down the
 140       *        list.
 141       */
 142      function getError($error, $error_text = '')
 143      {
 144      }
 145  
 146  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7