Adding Mobile phone numbers - New Zealand

Questions about modifications to Zuluru code, to add or change features
Post Reply
dcrobertson01
Posts: 20
Joined: Tue Mar 22, 2016 12:24 am

Adding Mobile phone numbers - New Zealand

Post by dcrobertson01 »

Hi - I am having some problems adding New Zealand phone numbers. I can add an ordinary nine digit number - such as 031234567, but when adding mobile numbers and free phone numbers, I get problems.

Mobile numbers:
I can add 021123456, and 02112345678, but not 0211234567

Free phone numbers
I can add 080012345 and 0800123456 and 080012345678, but not 08001234567

I thought it was something to do with models/person.php, but am not sure now. It looks to me as though it should the numbers correctly. But I'm a bit rusty on these things :-)

Code: Select all

if ($this->data[$this->alias]['addr_country'] == 'New Zealand') {
				$this->validate['addr_postalcode']['postal'] = array(
					'rule' => array('postal', '/^[0-9]{4}/', 'nz'),
					'message' => 'You must enter a valid New Zealand postal code',
				);
				$this->validate['home_phone']['phone']['rule'] = $this->validate['work_phone']['phone']['rule'] =
					$this->validate['mobile_phone']['phone']['rule'] = $this->validate['alternate_work_phone']['phone']['rule'] =
					$this->validate['alternate_mobile_phone']['phone']['rule'] = array('phone', '/^((03|04|06|07|09)\d{7})|((021|022|026|027|028|029)\d{6,8})|((0508|0800|0900)\d{5,8})$/');
			}
Also - numbers that will validate will also validate with additional characters on the end. eg 0211234567812345678910 will validate and get entered into the data base. 02112345678thisshouldbestopped will validate, but only the numerical part will get added to the data base.

This seems to stop it happening.

Code: Select all

$this->validate['alternate_mobile_phone']['phone']['rule'] = array('phone', '/(^(03|04|06|07|09)\d{7}$|^(021|022|026|027|028|029)\d{6,8}$|^(0508|0800|0900)\d{5,8}$)/');
But still does not validate my phone number :-(
GregS
Site Admin
Posts: 240
Joined: Thu Jan 06, 2011 4:58 pm

Re: Adding Mobile phone numbers - New Zealand

Post by GregS »

The code I put in for New Zealand numbers was done quickly; it's all going to be obsoleted with a better method in the new version. If you're just setting this up as a demonstration, maybe we can put a pin in this particular piece for the moment?
Clifford
Posts: 1
Joined: Tue Apr 11, 2017 3:09 am

Re: Adding Mobile phone numbers - New Zealand

Post by Clifford »

GregS wrote:The code I put in for New Zealand numbers was done quickly; it's all going to be obsoleted with a better method in the new version. If you're just setting this up as a demonstration, maybe we can put a pin in this particular piece for the moment?
Cool, when is the new version coming out?
Last edited by Clifford on Fri Jun 25, 2021 9:50 am, edited 4 times in total.
GregS
Site Admin
Posts: 240
Joined: Thu Jan 06, 2011 4:58 pm

Re: Adding Mobile phone numbers - New Zealand

Post by GregS »

Clifford wrote:Cool, when is the new version coming out?
I don't have a definitive date. It's been delayed now for far longer than I expected due to my being very busy with the projects that pay the bills. I'm working my way through adding automated testing, so that when it's released I can be confident that it's solid and not a big step backwards in terms of reliability.
GregS
Site Admin
Posts: 240
Joined: Thu Jan 06, 2011 4:58 pm

Re: Adding Mobile phone numbers - New Zealand

Post by GregS »

The new version of Zuluru has finally been released! See the release notice in the Announcements forum.
Post Reply