Changeset 7723 in spip-zone


Ignore:
Timestamp:
Dec 2, 2006, 12:45:35 PM (12 years ago)
Author:
bertrand@…
Message:

Upgrade au cvs Horde en passant par spip-zone/_dev_/genere_lib_sms

Location:
_plugins_/_dev_/sms/inc
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/_dev_/sms/inc/sms.php

    r7722 r7723  
    11<?php
    2 
    3 require_once 'PEAR.php';
     2// ATTENTION ! Genere avec makeSMSinc.sh et patch_SMS.php, NE PAS EDITER !
     3
     4include_spip('inc/c_pear');
    45
    56/**
     
    1112 * not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
    1213 *
    13  * $Horde: framework/Net_SMS/SMS.php,v 1.19 2006/01/01 21:10:07 jan Exp $
     14 * $Horde: framework/Net_SMS/SMS.php,v 1.20 2006/08/28 09:06:22 jan Exp $
    1415 *
    1516 * @author  Marko Djukic <marko@oblo.com>
     
    7980        }
    8081
    81         require_once 'Net/SMS/' . $gateway . '.php';
     82        include_spip('inc/sms/' . $gateway);
    8283        $class = 'Net_SMS_' . $gateway;
    8384        $info[$gateway] = call_user_func(array($class, 'getInfo'));
     
    102103        }
    103104
    104         require_once 'Net/SMS/' . $gateway . '.php';
     105        include_spip('inc/sms/' . $gateway);
    105106        $class = 'Net_SMS_' . $gateway;
    106107        $params[$gateway] = call_user_func(array($class, 'getParams'));
     
    127128        }
    128129
    129         require_once 'Net/SMS/' . $gateway . '.php';
     130        include_spip('inc/sms/' . $gateway);
    130131        $class = 'Net_SMS_' . $gateway;
    131132        $params[$gateway] = call_user_func(array($class, 'getDefaultSendParams'));
     
    180181     * @return mixed  True on success or PEAR Error on failure.
    181182     */
    182     function send(&$message)
     183    function send($message)
    183184    {
    184185        /* Authenticate. */
     
    287288    function &factory($driver, $params = array())
    288289    {
    289         include_once 'Net/SMS/' . $driver . '.php';
     290        include_spip('inc/sms/' . $driver);
    290291        $class = 'Net_SMS_' . $driver;
    291292        if (class_exists($class)) {
    292293            $sms = &new $class($params);
    293294        } else {
    294             $sms = PEAR::raiseError(sprintf(_("Class definition of %s not found."), $driver));
     295            $sms = c_PEAR::raiseError(sprintf(_("Class definition of %s not found."), $driver));
    295296        }
    296297
  • _plugins_/_dev_/sms/inc/sms/clickatell_http.php

    r7688 r7723  
    11<?php
     2// ATTENTION ! Genere avec makeSMSinc.sh et patch_SMS.php, NE PAS EDITER !
     3/**
     4 * @package Net_SMS
     5 */
     6
     7/**
     8 * HTTP_Request class.
     9 */
     10include_spip('inc/c_http_request');
     11
    212/**
    313 * Net_SMS_clickatell_http Class implements the HTTP API for accessing the
     
    919 * not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
    1020 *
    11  * $Horde: framework/Net_SMS/SMS/clickatell_http.php,v 1.20 2006/01/01 21:10:07 jan Exp $
     21 * $Horde: framework/Net_SMS/SMS/clickatell_http.php,v 1.25 2006/08/28 09:06:22 jan Exp $
    1222 *
    1323 * @author Marko Djukic <marko@oblo.com>
     
    6575        $response = Net_SMS_clickatell_http::_callURL($url);
    6676        if (is_a($response, 'PEAR_Error')) {
    67             return PEAR::raiseError(sprintf(_("Authentication failed. %s"), $response->getMessage()));
     77            return c_PEAR::raiseError(sprintf(_("Authentication failed. %s"), $response->getMessage()));
    6878        }
    6979
     
    8595     * @param array $message  The array containing the message and its send
    8696     *                        parameters.
    87      * @param string $to      The destination string.
     97     * @param array $to       The recipients.
    8898     *
    8999     * @return array  An array with the success status and additional
    90100     *                information.
    91101     */
    92     function _send(&$message, $to)
     102    function _send($message, $to)
    93103    {
    94104        /* Set up the http sending url. */
     
    182192    function getInfo()
    183193    {
    184         $info['name'] = _("Clickatell via HTTP");
    185         $info['desc'] = _("This driver allows sending of messages through the Clickatell (http://clickatell.com) gateway, using the HTTP API");
    186 
    187         return $info;
     194        return array(
     195            'name' => _("Clickatell via HTTP"),
     196            'desc' => _("This driver allows sending of messages through the Clickatell (http://clickatell.com) gateway, using the HTTP API"),
     197        );
    188198    }
    189199
     
    195205    function getParams()
    196206    {
    197         $params = array();
    198         $params['user']     = array('label' => _("Username"), 'type' => 'text');
    199         $params['password'] = array('label' => _("Password"), 'type' => 'text');
    200         $params['api_id']   = array('label' => _("API ID"), 'type' => 'text');
    201 
    202         return $params;
     207        return array(
     208            'user' => array('label' => _("Username"), 'type' => 'text'),
     209            'password' => array('label' => _("Password"), 'type' => 'text'),
     210            'api_id' => array('label' => _("API ID"), 'type' => 'text'),
     211        );
    203212    }
    204213
     
    223232            'params' => array(array('now' => _("immediate"), 'user' => _("user select"))));
    224233
    225         $types = array('SMS_TEXT' => 'SMS_TEXT', 'SMS_FLASH' => 'SMS_FLASH');
     234        $types = array('SMS_TEXT' => _("Standard"), 'SMS_FLASH' => _("Flash"));
    226235        $params['msg_type'] = array(
    227236            'label' => _("Message type"),
    228             'type' => 'multienum',
     237            'type' => 'keyval_multienum',
    229238            'params' => array($types));
    230239
     
    318327            return $errors[$error];
    319328        } else {
    320             return PEAR::raiseError(sprintf($error_text, $errors[$error]));
     329            return c_PEAR::raiseError(sprintf($error_text, $errors[$error]));
    321330        }
    322331    }
     
    333342    function _callURL($url)
    334343    {
    335         $options['method'] = 'POST';
     344        $options['method'] = 'GET';
    336345        $options['timeout'] = 5;
    337346        $options['allowRedirects'] = true;
    338347
    339         if (!@include_once 'HTTP/Request.php') {
    340             return PEAR::raiseError(_("Missing PEAR package HTTP_Request."));
    341         }
    342         $http = &new HTTP_Request($this->_base_url . $url, $options);
     348        $http = new HTTP_Request($this->_base_url . $url, $options);
    343349        @$http->sendRequest();
    344350        if ($http->getResponseCode() != 200) {
    345             return PEAR::raiseError(sprintf(_("Could not open %s."), $url));
     351            return c_PEAR::raiseError(sprintf(_("Could not open %s."), $url));
    346352        }
    347353
  • _plugins_/_dev_/sms/inc/sms/generic_smtp.php

    r7688 r7723  
    11<?php
     2// ATTENTION ! Genere avec makeSMSinc.sh et patch_SMS.php, NE PAS EDITER !
    23/**
    34 * Generic e-mail based SMS driver
     
    1112 * carriers, particularly those based in the U.S.
    1213 *
    13  * $Horde: framework/Net_SMS/SMS/generic_smtp.php,v 1.10 2006/01/01 21:10:07 jan Exp $
     14 * $Horde: framework/Net_SMS/SMS/generic_smtp.php,v 1.13 2006/08/28 09:39:09 jan Exp $
    1415 *
    1516 * @category   Networking
     
    9091        return array(
    9192            'name' => _("Email-to-SMS Gateway"),
    92             'desc' => _("EMail-to-SMS gateway driver, for carriers which provide this service.")
     93            'desc' => _("This driver allows sending of messages through an email-to-SMS gateway, for carriers which provide this service.")
    9394        );
    9495    }
     
    103104        return array(
    104105            'carrier'     => array('label' => _("Carrier"), 'type' => 'text'),
    105             'mailBackend' => array('label' => _("PEAR::Mail backend"), 'type' => 'text')
     106            'mailBackend' => array('label' => _("c_PEAR::Mail backend"), 'type' => 'text')
    106107        );
    107108    }
     
    117118     *
    118119     * @param array $message  Message to send.
    119      * @param string $to      Destination phone number.
     120     * @param string $to      The recipient.
    120121     *
    121122     * @return array  An array with the success status and additional
    122123     *                information.
    123124     */
    124     function _send(&$message, $to)
     125    function _send($message, $to)
    125126    {
    126127        $response = array();
    127128        $destemail = $this->_getDest($to);
    128         require_once 'Mail.php';
    129         $m = Mail::factory($this->_params['mailBackend'], $this->_params['mailParams']);
     129        include_spip('inc/c_mail');
     130        $m = &c_Mail::factory($this->_params['mailBackend'],
     131                            $this->_params['mailParams']);
    130132
    131133        if (isset($message['carrier'])) {
     
    135137        }
    136138
    137         $res =& $m->send($dest, $this->_params['mailHeaders'], $message['text']);
    138         if (PEAR::isError($res)) {
    139             $response[$to] = array(0, $res->getMessage());
     139        $res = $m->send($dest, $this->_params['mailHeaders'], $message['text']);
     140        if (c_PEAR::isError($res)) {
     141            return array(0, $res->getMessage());
    140142        } else {
    141             $response[$to] = array(1, null);
     143            return array(1, null);
    142144        }
    143 
    144         return $response;
    145145    }
    146146
     
    187187        $this->_carriers[$name] = $addr;
    188188    }
     189
     190    /**
     191     * Returns a list of parameters specific for this driver.
     192     *
     193     * @return array Default sending parameters.
     194     */
     195    function getDefaultSendParams()
     196    {
     197        return array();
     198    }
     199
    189200}
  • _plugins_/_dev_/sms/inc/sms/sms2email_http.php

    r7688 r7723  
    11<?php
     2// ATTENTION ! Genere avec makeSMSinc.sh et patch_SMS.php, NE PAS EDITER !
     3/**
     4 * @package Net_SMS
     5 */
     6
     7/**
     8 * HTTP_Request class.
     9 */
     10include_spip('inc/c_http_request');
     11
    212/**
    313 * Net_SMS_sms2email_http Class implements the HTTP API for accessing the
     
    919 * not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
    1020 *
    11  * $Horde: framework/Net_SMS/SMS/sms2email_http.php,v 1.33 2006/01/01 21:10:07 jan Exp $
     21 * $Horde: framework/Net_SMS/SMS/sms2email_http.php,v 1.37 2006/08/28 09:06:22 jan Exp $
    1222 *
    1323 * @author Marko Djukic <marko@oblo.com>
     
    4757     * @param array $message  The array containing the message and its send
    4858     *                        parameters.
    49      * @param string $to      The destination string.
     59     * @param array $to       The recipients.
    5060     *
    5161     * @return array  An array with the success status and additional
    5262     *                information.
    5363     */
    54     function _send(&$message, $to)
     64    function _send($message, $to)
    5565    {
    5666        /* Set up the sending url. */
     
    281291        $length = substr($response, 19);
    282292        if (strlen($contacts_str) != $length) {
    283             return PEAR::raiseError(_("Could not fetch complete address book."));
     293            return c_PEAR::raiseError(_("Could not fetch complete address book."));
    284294        }
    285295        $contacts_lines = explode("\n", $contacts_str);
     
    444454        $length = substr($response, 22);
    445455        if (strlen($lists_str) != $length) {
    446             return PEAR::raiseError(_("Could not fetch the complete list of distribution lists."));
     456            return c_PEAR::raiseError(_("Could not fetch the complete list of distribution lists."));
    447457        }
    448458        $lists_lines = explode("\n", $lists_str);
     
    491501        $length = substr($response, 22);
    492502        if (strlen($list_str) != $length) {
    493             return PEAR::raiseError(_("Could not fetch complete distribution list."));
     503            return c_PEAR::raiseError(_("Could not fetch complete distribution list."));
    494504        }
    495505        $list_str = trim($list_str);
     
    512522    function getInfo()
    513523    {
    514         $info['name'] = _("sms2email via HTTP");
    515         $info['desc'] = _("This driver allows sending of messages through the sms2email (http://sms2email.com) gateway, using the HTTP API");
    516 
    517         return $info;
     524        return array(
     525            'name' => _("sms2email via HTTP"),
     526            'desc' => _("This driver allows sending of messages through the sms2email (http://sms2email.com) gateway, using the HTTP API"),
     527        );
    518528    }
    519529
     
    565575            'params' => array(array('now' => _("immediate"), 'user' => _("user select"))));
    566576
    567         $types = array('SMS_TEXT' => 'SMS_TEXT', 'SMS_FLASH' => 'SMS_FLASH');
     577        $types = array('SMS_TEXT' => _("Standard"), 'SMS_FLASH' => _("Flash"));
    568578        $params['msg_type'] = array(
    569579            'label' => _("Message type"),
    570             'type' => 'multienum',
     580            'type' => 'keyval_multienum',
    571581            'params' => array($types));
    572582
     
    648658            return $errors[$error];
    649659        } else {
    650             return PEAR::raiseError(sprintf($error_text, $errors[$error]));
     660            return c_PEAR::raiseError(sprintf($error_text, $errors[$error]));
    651661        }
    652662    }
     
    669679        $url = (empty($this->_params['ssl']) ? 'http://' : 'https://') . $this->_base_url . $url;
    670680
    671         if (!@include_once 'HTTP/Request.php') {
    672             return PEAR::raiseError(_("Missing PEAR package HTTP_Request."));
    673         }
    674         $http = &new HTTP_Request($url, $options);
     681        $http = new HTTP_Request($url, $options);
    675682        @$http->sendRequest();
    676683        if ($http->getResponseCode() != 200) {
    677             return PEAR::raiseError(sprintf(_("Could not open %s."), $url));
     684            return c_PEAR::raiseError(sprintf(_("Could not open %s."), $url));
    678685        }
    679686
  • _plugins_/_dev_/sms/inc/sms/vodafoneitaly_smtp.php

    r7688 r7723  
    11<?php
     2// ATTENTION ! Genere avec makeSMSinc.sh et patch_SMS.php, NE PAS EDITER !
    23/**
    34 * Net_SMS_vodafoneitaly_smtp Class implements the SMTP API for accessing the
     
    1112 * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
    1213 *
    13  * $Horde: framework/Net_SMS/SMS/vodafoneitaly_smtp.php,v 1.18 2006/01/01 21:10:07 jan Exp $
     14 * $Horde: framework/Net_SMS/SMS/vodafoneitaly_smtp.php,v 1.20 2006/08/28 09:06:22 jan Exp $
    1415 *
    1516 * @author Marko Djukic <marko@oblo.com>
     
    4849     * @param array $message  The array containing the message and its send
    4950     *                        parameters.
    50      * @param string $to      The destination string.
     51     * @param string $to      The recipient.
    5152     *
    5253     * @return array  An array with the success status and additional
    5354     *                information.
    5455     */
    55     function _send(&$message, $to)
     56    function _send($message, $to)
    5657    {
    57         if (!@include_once 'Mail.php') {
    58             return PEAR::raiseError(_("Missing required PEAR package Mail."));
    59         }
    60         $mailer = Mail::factory('mail');
    61 
    6258        /* Since this only works for Italian numbers, this is hardcoded. */
    6359        if (preg_match('/^.*?<?(\+?39)?(\d{10})>?/', $to, $matches)) {
    6460            $headers['From'] = $this->_params['user'];
    6561            $to = $matches[2] . '@sms.vodafone.it';
     62
     63            $mailer = c_Mail::factory('mail');
    6664            $result = $mailer->send($to, $headers, $message['text']);
    6765            if (is_a($result, 'PEAR_Error')) {
     
    8280    function getInfo()
    8381    {
    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;
     82        return array(
     83            'name' => _("Vodafone Italy via SMTP"),
     84            '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)."),
     85        );
    8886    }
    8987
     
    9593    function getParams()
    9694    {
    97         $params = array();
    98         $params['user']       = array('label'  => _("Username"),
    99                                       'type'   => 'text');
    100 
    101         return $params;
     95        return array('user' => array('label' => _("Username"),
     96                                     'type' => 'text'));
    10297    }
    10398
  • _plugins_/_dev_/sms/inc/sms/win_http.php

    r7688 r7723  
    11<?php
     2// ATTENTION ! Genere avec makeSMSinc.sh et patch_SMS.php, NE PAS EDITER !
     3/**
     4 * @package Net_SMS
     5 */
     6
     7/**
     8 * HTTP_Request class.
     9 */
     10include_spip('inc/c_http_request');
     11
    212/**
    313 * Net_SMS_win_http Class implements the HTTP API for accessing the WIN
     
    919 * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
    1020 *
    11  * $Horde: framework/Net_SMS/SMS/win_http.php,v 1.10 2006/01/01 21:10:07 jan Exp $
     21 * $Horde: framework/Net_SMS/SMS/win_http.php,v 1.13 2006/08/28 09:06:22 jan Exp $
    1222 *
    1323 * @author Marko Djukic <marko@oblo.com>
     
    4757     * @param array $message  The array containing the message and its send
    4858     *                        parameters.
    49      * @param string $to      The destination string.
     59     * @param array $to       The destination string.
    5060     *
    5161     * @return array  An array with the success status and additional
    5262     *                information.
    5363     */
    54     function _send(&$message, $to)
     64    function _send($message, $to)
    5565    {
    5666        /* Start the XML. */
     
    131141    function getInfo()
    132142    {
    133         $info['name'] = _("WIN via HTTP");
    134         $info['desc'] = _("This driver allows sending of messages through the WIN (http://winplc.com) gateway, using the HTTP API");
    135 
    136         return $info;
     143        return array(
     144            'name' => _("WIN via HTTP"),
     145            'desc' => _("This driver allows sending of messages through the WIN (http://winplc.com) gateway, using the HTTP API"),
     146        );
    137147    }
    138148
     
    225235            return $errors[$error];
    226236        } else {
    227             return PEAR::raiseError(sprintf($error_text, $errors[$error]));
     237            return c_PEAR::raiseError(sprintf($error_text, $errors[$error]));
    228238        }
    229239    }
     
    247257        $xml = '<?xml version="1.0" standalone="no"?><!DOCTYPE WIN_DELIVERY_2_SMS SYSTEM "winbound_messages_v1.dtd"><WIN_DELIVERY_2_SMS>' . $xml . '</WIN_DELIVERY_2_SMS>';
    248258
    249         if (!@include_once 'HTTP/Request.php') {
    250             return PEAR::raiseError(_("Missing PEAR package HTTP_Request."));
    251         }
    252         $http = &new HTTP_Request($this->_base_url, $options);
     259        $http = new HTTP_Request($this->_base_url, $options);
    253260
    254261        /* Add the authentication values to POST. */
     
    260267        @$http->sendRequest();
    261268        if ($http->getResponseCode() != 200) {
    262             return PEAR::raiseError(sprintf(_("Could not open %s."), $this->_base_url));
     269            return c_PEAR::raiseError(sprintf(_("Could not open %s."), $this->_base_url));
    263270        }
    264271
Note: See TracChangeset for help on using the changeset viewer.