Download & Extend

SMS User, strip 0 and add country code

Project:SMS Framework
Version:6.x-1.0
Component:SMS User
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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

Comments

#1

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

#2

Further Update

When I enter a mobile number into an account, the number that the confirmation SMS is being sent to ( using the Clickatell gateway) is what I have typed into the box, not the formatted number.

E.g., if I type 012 123 456, the number is displayed as 12123456, as expected. The log though shows an attempt to send an SMS to 012 123 456, with no country code added (which should be done by sms_clickatell_send().

Glenn

#3

Category:feature request» bug report

#4

Version:6.x-1.0-beta1» 6.x-1.0

#5

OK, I can get a confirmation SMS sent by entering the mobile number, without the leading '0', an selecting the country. Confirmation works fine.

The send function fails though when attempting to send a notification of a new node creation. I get a 114 error because the country code is not being added on the front.

Glenn

#6

My comments are really a different issue to the original, so have moved it to http://drupal.org/node/679698