Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple numbers in compose with manual input #479

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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