updated vodia identity

This commit is contained in:
Luca Haid
2025-08-07 13:05:07 +00:00
parent fed87a236c
commit 4313cf70c0
4 changed files with 139 additions and 11 deletions
+11 -5
View File
@@ -414,12 +414,18 @@ class AddressModel {
}
}
if (array_key_exists("pfm", $filter)) {
$pfm = FronkDB::singleton()->escape($filter["pfm"]);
if ($pfm) {
$where .= " AND (phone like '%$pfm%' OR fax like '%$pfm%' OR mobile like '%$pfm%' )";
$pfm = preg_replace('/^(43|0)/', '', preg_replace('/[^0-9]/', '', $filter['pfm'] ?? ''));
if (!empty($pfm)) {
$pfmEscaped = FronkDB::singleton()->escape($pfm);
$searchColumns = ['phone', 'fax', 'mobile'];
$conditions = array_map(function ($column) use ($pfmEscaped) {
$normalizedColumn = "REGEXP_REPLACE(REGEXP_REPLACE(`$column`, '[^0-9]', ''), '^(43|0)', '')";
return "$normalizedColumn LIKE '%$pfmEscaped%'";
}, $searchColumns);
$where .= " AND (" . implode(' OR ', $conditions) . ")";
}
}
if (array_key_exists("billing_type", $filter)) {
$billing_type = FronkDB::singleton()->escape($filter["billing_type"]);
+41
View File
@@ -441,6 +441,9 @@ class UserController extends mfBaseController
case "setVodiaIdentity":
$return = $this->setVodiaIdentityApi();
break;
case "getVodiaCall":
$return = $this->getVodiaCallApi();
break;
default:
$return = false;
}
@@ -528,6 +531,44 @@ class UserController extends mfBaseController
}
private function getVodiaCallApi() {
if(!ENABLE_VODIA_IDENTITY_SWITCHER) {
return ["enabled" => false];
}
$domain = $this->me->getFlag("vodia_identity_domain")->value();
$username = $this->me->getFlag("vodia_identity_username")->value();
if(!$domain || !$username) {
return ["enabled" => false];
}
$vodia = new Vodia_Api(VODIA_API_URL, VODIA_API_ADMIN_USER, VODIA_API_ADMIN_PASS);
$calls = $vodia->getActiveCalls($domain, $username);
if(!$calls) {
return ["enabled" => true, "calls" => []];
}
$from = null;
foreach($calls as $call) {
if(isset($call['from'])) {
$from = $call['from'];
if(preg_match('/<sip:([^@]+)@/', $from, $m)) {
$from = $m[1];
} elseif(preg_match('/<([^>]+)>/', $from, $m)) {
$from = $m[1];
} else {
$from = str_replace('"', '', $from);
}
break; // only return the first call's from number
}
}
return ["enabled" => true, "number" => $from];
}
private function startSuperexpertApi() {
$me = new User();
$me->loadMe();