fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [9940] sms: more on pswin


From: Sigurd Nes
Subject: [Fmsystem-commits] [9940] sms: more on pswin
Date: Thu, 30 Aug 2012 17:39:41 +0000

Revision: 9940
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9940
Author:   sigurdne
Date:     2012-08-30 17:39:40 +0000 (Thu, 30 Aug 2012)
Log Message:
-----------
sms: more on pswin

Modified Paths:
--------------
    trunk/sms/inc/plugin/gateway/pswin/get.php
    trunk/sms/inc/plugin/gateway/pswin/soap.php
    trunk/sms/setup/default_records.inc.php
    trunk/sms/setup/setup.inc.php
    trunk/sms/setup/tables_current.inc.php
    trunk/sms/setup/tables_update.inc.php

Modified: trunk/sms/inc/plugin/gateway/pswin/get.php
===================================================================
--- trunk/sms/inc/plugin/gateway/pswin/get.php  2012-08-30 12:55:34 UTC (rev 
9939)
+++ trunk/sms/inc/plugin/gateway/pswin/get.php  2012-08-30 17:39:40 UTC (rev 
9940)
@@ -15,38 +15,75 @@
 
                function 
gw_set_delivery_status($gp_code="",$uid="",$smslog_id="",$p_datetime="",$p_update="")
                {
-return;
-                   // p_status :
-                   // 0 = pending
-                   // 1 = delivered
-                   // 2 = failed
-
-                       if($result['statuscode'] == 1)
-                       {
-                           $this->setsmsdeliverystatus($smslog_id,$uid,1);     
                
-                       }
-                       else if($result['statuscode'] == 5)
-                       {
-                           $this->setsmsdeliverystatus($smslog_id,$uid,2);     
                
-                       }
-
-                   return;
+                   // nothing
                }
 
-
-
                function gw_set_incoming_action()
                {
-                       $test_receive = true;
+                       $strip_code = isset($this->pswin_param['strip_code']) 
&& $this->pswin_param['strip_code'] ? $this->pswin_param['strip_code'] : '';
                        
+                       $test_receive = false;
+                       
                        if ($test_receive)
                        {
                                $this->test_receive();
                        }
 
-                       
+                       $sql = 'SELECT * FROM phpgw_sms_received_data WHERE 
status = 0 AND type = \'sms\'';
+                       $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
 
+                       $messages = array();
+                       while ($GLOBALS['phpgw']->db->next_record())
+                       {
+                               $messages[] = array
+                               (
+                                       'id'                    => 
$GLOBALS['phpgw']->db->f('id'),
+                                       'type'                  => 
$GLOBALS['phpgw']->db->f('type'),
+                                       'entry_date'    => 
$GLOBALS['phpgw']->db->f('entry_date'),
+                                       'data'                  => 
unserialize($GLOBALS['phpgw']->db->f('data',true))
+                               );
+                       }
 
+//                     _debug_array($messages);
+
+
+                       foreach($messages as $entry)
+                       {
+                               $message =  $entry['data']->m->Text;
+                               if($strip_code)
+                               {
+                                       $message_arr = 
explode(strtolower($strip_code), strtolower($message));
+                                       $message = 
ucfirst(trim($message_arr[1]));
+                               }
+                               
+                           $array_target_code = explode(' ',$message);
+//_debug_array($array_target_code);
+                           $target_code = 
strtoupper(trim($array_target_code[0]));
+
+                           $message = $array_target_code[1];
+
+                           for ($i=2;$i<count($array_target_code);$i++)
+                           {
+                                       $message .= " {$array_target_code[$i]}";
+                           }
+                               
+                               $sms_datetime   = $entry['entry_date'];
+                               $sms_sender             = 
$entry['data']->m->SenderNumber;
+/*
+_debug_array($sms_datetime);
+_debug_array($sms_sender);
+_debug_array($target_code);
+_debug_array($message);
+*/
+                               if 
(parent::setsmsincomingaction($sms_datetime,$sms_sender,$target_code,$message))
+                               {
+                                       $sql = 'UPDATE phpgw_sms_received_data 
SET status = 1 WHERE id =' . (int) $entry['id'];
+//_debug_array($sql);
+                                       
$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+                               }                       
+                       }
+//                     die();
+
                }
 
 
@@ -56,7 +93,7 @@
 
                        $options=array();
                        $options['soap_version']        = SOAP_1_2;
-                       $options['location']            = 
'http://localhost/~sn5607/savannah_trunk/sms/inc/plugin/gateway/pswin/soap.php?domain=test';//$this->pswin_param['receive_url'];
+                       $options['location']            = 
'http://localhost/~sn5607/savannah_trunk/sms/inc/plugin/gateway/pswin/soap.php?domain=bbb';//$this->pswin_param['receive_url'];
                        $options['uri']                         = 
"http://localhost/~sn5607/savannah_trunk/sms/inc/plugin/gateway/pswin/soap.php";;
                        $options['trace']                       = 1;
                //      $options['proxy_host']          = 
$this->pswin_param['proxy_host'];
@@ -86,26 +123,8 @@
 
                        $result = $ReturnValue->ReceiveSMSMessageResult;
 
-       _debug_array($result);die();
+                       _debug_array($result);
 
-                       $sms = array();
 
-                       foreach($sms as $entry)
-                       {
-                               $sms_datetime   = $entry[''];
-                               $sms_sender             = $entry[''];
-                               $target_code    = $entry[''];
-                               $message                = $entry['message'];
-                               
-                               if 
(!parent::setsmsincomingaction($sms_datetime,$sms_sender,$target_code,$message))
-                               {
-                                       $bofelamimail->flagMessages($_flag = 
'unread', array($entry['uid']));
-                               }                       
-                       }
-
-                       if($connectionStatus == 'true')
-                       {
-                               $bofelamimail->closeConnection();
-                       }
                }
        }

Modified: trunk/sms/inc/plugin/gateway/pswin/soap.php
===================================================================
--- trunk/sms/inc/plugin/gateway/pswin/soap.php 2012-08-30 12:55:34 UTC (rev 
9939)
+++ trunk/sms/inc/plugin/gateway/pswin/soap.php 2012-08-30 17:39:40 UTC (rev 
9940)
@@ -177,8 +177,6 @@
 
                $ReceiveSMSMessageResponse = new ReceiveSMSMessageResponse();
                $ReturnValue = new ReturnValue();
-               $ReturnValue->Code = '500';
-               $ReturnValue->Description = '';
                $ReturnValue->Reference = '';
 
                $value_set = array
@@ -191,18 +189,34 @@
 
                $cols = implode(',', array_keys($value_set));
                $values = 
$GLOBALS['phpgw']->db->validate_insert(array_values($value_set));
-               if(     $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sms_reveived_data ({$cols}) VALUES ({$values})",__LINE__,__FILE__))
+               
+               $GLOBALS['phpgw']->db->Exception_On_Error = true;
+               
+               try
                {
-                       $ReturnValue->Code = '200';             
+                       $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sms_received_data ({$cols}) VALUES ({$values})",__LINE__,__FILE__);
                }
+
+               catch(PDOException $e)
+               {
+               }
+
+               if ( $e )
+               {
+                       $ReturnValue->Description = $e->getMessage();
+                       $ReturnValue->Code = 500;       
+               }
+               else
+               {
+                       $ReturnValue->Description = 'All is good';
+                       $ReturnValue->Code = 200;               
+               }
                
                $ReceiveSMSMessageResponse->ReceiveSMSMessageResult = 
$ReturnValue;
 
                return $ReceiveSMSMessageResponse;
-       } 
+       }
 
-
-
        function ReceiveMMSMessage($ReceiveMMSMessage)
        {
                if($error = check_error())
@@ -226,7 +240,7 @@
 
                $cols = implode(',', array_keys($value_set));
                $values = 
$GLOBALS['phpgw']->db->validate_insert(array_values($value_set));
-               if(     $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sms_reveived_data ({$cols}) VALUES ({$values})",__LINE__,__FILE__))
+               if(     $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sms_received_data ({$cols}) VALUES ({$values})",__LINE__,__FILE__))
                {
                        $ReturnValue->Code = '200';             
                }
@@ -260,7 +274,7 @@
 
                $cols = implode(',', array_keys($value_set));
                $values = 
$GLOBALS['phpgw']->db->validate_insert(array_values($value_set));
-               if(     $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sms_reveived_data ({$cols}) VALUES ({$values})",__LINE__,__FILE__))
+               if(     $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sms_received_data ({$cols}) VALUES ({$values})",__LINE__,__FILE__))
                {
                        $ReturnValue->Code = '200';             
                }
@@ -300,6 +314,12 @@
 
        if ($_SERVER["REQUEST_METHOD"] == "POST")
        {
+/*
+               $filename = '/tmp/test_soap.txt';
+               $fp = fopen($filename, "wb");
+               fwrite($fp,serialize($request_xml));
+               fclose($fp);
+*/
                $GLOBALS['server']->handle($request_xml);
        }
        else

Modified: trunk/sms/setup/default_records.inc.php
===================================================================
--- trunk/sms/setup/default_records.inc.php     2012-08-30 12:55:34 UTC (rev 
9939)
+++ trunk/sms/setup/default_records.inc.php     2012-08-30 17:39:40 UTC (rev 
9940)
@@ -102,6 +102,7 @@
        $db->query("INSERT INTO phpgw_config2_attrib 
(section_id,id,input_type,name, descr) VALUES (" . (7 + $num_sections) . ", 8, 
'text', 'originator', 'originator')");
        $db->query("INSERT INTO phpgw_config2_attrib 
(section_id,id,input_type,name, descr) VALUES (" . (7 + $num_sections) . ", 9, 
'listbox', 'type', 'Send type')");
        $db->query("INSERT INTO phpgw_config2_attrib 
(section_id,id,input_type,name, descr) VALUES (" . (7 + $num_sections) . ", 10, 
'text', 'receive_url', 'receive_url using SOAP')");
+       $db->query("INSERT INTO phpgw_config2_attrib 
(section_id,id,input_type,name, descr) VALUES (" . (7 + $num_sections) . ", 11, 
'text', 'strip_code', 'Strip code from message')");
 
        $db->query("INSERT INTO phpgw_config2_choice 
(section_id,attrib_id,id,value) VALUES (" . (1 + $num_sections) . ", 1, 1, 
'gnokii')");
        $db->query("INSERT INTO phpgw_config2_choice 
(section_id,attrib_id,id,value) VALUES (" . (1 + $num_sections) . ", 1, 2, 
'clickatell')");

Modified: trunk/sms/setup/setup.inc.php
===================================================================
--- trunk/sms/setup/setup.inc.php       2012-08-30 12:55:34 UTC (rev 9939)
+++ trunk/sms/setup/setup.inc.php       2012-08-30 17:39:40 UTC (rev 9940)
@@ -50,7 +50,7 @@
                'phpgw_sms_tblusergroupphonebook_public',
                'phpgw_sms_tbluserinbox',
                'phpgw_sms_tbluserphonebook',
-               'phpgw_sms_reveived_data'
+               'phpgw_sms_received_data'
        );
 
        /* The hooks this app includes, needed for hooks registration */

Modified: trunk/sms/setup/tables_current.inc.php
===================================================================
--- trunk/sms/setup/tables_current.inc.php      2012-08-30 12:55:34 UTC (rev 
9939)
+++ trunk/sms/setup/tables_current.inc.php      2012-08-30 17:39:40 UTC (rev 
9940)
@@ -311,7 +311,7 @@
                        'uc' => array()
                ),
 
-               'phpgw_sms_reveived_data' => array(
+               'phpgw_sms_received_data' => array(
                        'fd' => array(
                                'id' => array('type' => 'auto', 'nullable' => 
False),
                                'type' => array('type' => 'varchar', 
'precision' => 15, 'nullable' => False),,/*sms/mms/report*/

Modified: trunk/sms/setup/tables_update.inc.php
===================================================================
--- trunk/sms/setup/tables_update.inc.php       2012-08-30 12:55:34 UTC (rev 
9939)
+++ trunk/sms/setup/tables_update.inc.php       2012-08-30 17:39:40 UTC (rev 
9940)
@@ -531,7 +531,7 @@
 
 
                $GLOBALS['phpgw_setup']->oProc->CreateTable(
-                       'phpgw_sms_reveived_data', array(
+                       'phpgw_sms_received_data', array(
                                'fd' => array(
                                        'id' => array('type' => 'auto', 
'nullable' => False),
                                        'type' => array('type' => 'varchar', 
'precision' => 15, 'nullable' => False),/*sms/mms/report*/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]