Skip to content

Commit

Permalink
support multiple numbers in compose with manual input
Browse files Browse the repository at this point in the history
Closes #478
  • Loading branch information
tenzap committed Oct 14, 2022
1 parent 58458aa commit 541f5a5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions application/controllers/Kalkun.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,32 @@ function phone_number_validation()
echo json_encode($result);
}

// --------------------------------------------------------------------

/**
* Check multiple phone number validity
*
* returns a json string used by jquery validation plugin
* "true" if all phone numbers are valid
* "an error message with the faulty number" if not
*/
function phone_number_validation_multiple()
{
$tmp_dest = explode(',', $this->input->get_post('phone'));
foreach ($tmp_dest as $key => $val)
{
$result = is_phone_number_valid($val, $this->input->get_post('region'));
if ($result !== TRUE)
{
header('Content-type: application/json');
echo json_encode($result.' ('.trim($val).')');
return;
}
}
header('Content-type: application/json');
echo json_encode('true');
}

function get_csrf_hash()
{
header('Content-type: application/json');
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function compose_process()
$tmp_dest = explode(',', $this->input->post('manualvalue'));
foreach ($tmp_dest as $key => $tmp)
{
$this->_phone_number_validation($this->input->post('manualvalue'));
$this->_phone_number_validation($tmp);
$dest[$key] = phone_format_e164($tmp);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion application/views/js_init/message/js_compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function onTagInputKeydown(e) {
manualvalue: {
required: "#sendoption3:checked",
remote: {
url: "<?php echo site_url('kalkun/phone_number_validation'); ?>",
url: "<?php echo site_url('kalkun/phone_number_validation_multiple'); ?>",
type: "get",
data: {
phone: function() {
Expand Down

0 comments on commit 541f5a5

Please sign in to comment.