SMS User, strip 0 and add country code

mckeen_greg - July 27, 2009 - 10:43
Project:SMS Framework
Version:6.x-1.0-beta1
Component:SMS User
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi there,

As per this issue: http://drupal.org/node/514696, it would also be nice to have this done when users enter the phone number into the submission form to save the number into the database without the 0.

I have attached a patch if you are interested in integrating this.

--- sms_user.module.orig  2009-07-27 12:35:48.000000000 +0200
+++ sms_user.module 2009-07-27 12:31:40.000000000 +0200
@@ -344,6 +344,8 @@
   if (($category == 'mobile' || $category == 'account') && $edit['sms_user']) {
     foreach ($edit['sms_user'] as $delta => $number) {
       if (is_numeric($delta)) {
+        //strip the 0, and add the country code to the mobile number
+        $number['number'] = $number['gateway']['country'] . ltrim($number['number'],0);
         $db_values = array($number['number'], $number['status'], isset($number['code']) ? $number['code'] : NULL, serialize($number['gateway']));
         if (isset($account->sms_user[$delta])) {
           db_query("UPDATE {sms_user} SET number = '%s', status = %d, code = '%s', gateway = '%s'

AttachmentSize
sms_user_strip_zero.patch762 bytes

#1

glennnz - November 19, 2009 - 02:11

This, and the sms_user module, is failing completely for me.

When I enter a number (before applying this patch), no number would be saved to the database.

After applying this patch, only the country code is saved, no further number at all.

:-(

Thanks

Glenn

 
 

Drupal is a registered trademark of Dries Buytaert.