mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 19:53:56 +00:00
Simplify the registrations count method by using the get method.
This commit is contained in:
@@ -64,7 +64,7 @@ if (!class_exists('registrations')) {
|
|||||||
/**
|
/**
|
||||||
* get the registrations
|
* get the registrations
|
||||||
*/
|
*/
|
||||||
public function get($profile) {
|
public function get($profile = 'all') {
|
||||||
|
|
||||||
//initialize the id used in the registrations array
|
//initialize the id used in the registrations array
|
||||||
$id = 0;
|
$id = 0;
|
||||||
@@ -196,53 +196,15 @@ if (!class_exists('registrations')) {
|
|||||||
*/
|
*/
|
||||||
public function count($profile = 'all') {
|
public function count($profile = 'all') {
|
||||||
|
|
||||||
//set the initial count value to 0
|
//use get the registrations to count
|
||||||
$count = 0;
|
$registrations = $this->get($profile);
|
||||||
|
|
||||||
//create the event socket connection
|
//set the count
|
||||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
$count = @sizeof($registrations);
|
||||||
|
|
||||||
//get the default settings
|
|
||||||
$sql = "select sip_profile_name from v_sip_profiles ";
|
|
||||||
$sql .= "where sip_profile_enabled = 'true' ";
|
|
||||||
if ($profile != 'all' && $profile != '') {
|
|
||||||
$sql .= "and sip_profile_name = :sip_profile_name ";
|
|
||||||
$parameters['sip_profile_name'] = $profile;
|
|
||||||
}
|
|
||||||
$database = new database;
|
|
||||||
$sip_profiles = $database->select($sql, $parameters, 'all');
|
|
||||||
if (is_array($sip_profiles) && @sizeof($sip_profiles) != 0) {
|
|
||||||
foreach ($sip_profiles as $field) {
|
|
||||||
|
|
||||||
//get sofia status profile information including registrations
|
|
||||||
$cmd = "api sofia xmlstatus profile ".$field['sip_profile_name']." reg";
|
|
||||||
$xml_response = trim(event_socket_request($fp, $cmd));
|
|
||||||
|
|
||||||
if ($xml_response == "Invalid Profile!") { $xml_response = "<error_msg>".$text['label-message']."</error_msg>"; }
|
|
||||||
$xml_response = str_replace("<profile-info>", "<profile_info>", $xml_response);
|
|
||||||
$xml_response = str_replace("</profile-info>", "</profile_info>", $xml_response);
|
|
||||||
if (strlen($xml_response) > 101) {
|
|
||||||
try {
|
|
||||||
$xml = new SimpleXMLElement($xml_response);
|
|
||||||
}
|
|
||||||
catch(Exception $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$array = json_decode(json_encode($xml), true);
|
|
||||||
if (is_array($array['registrations']['registration'][0])) {
|
|
||||||
$count = $count + @sizeof($array['registrations']['registration']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$count = $count + @sizeof($array['registrations']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//return the registrations count
|
//return the registrations count
|
||||||
return $count;
|
return $count;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user