fusionpbx/app/switch/resources/classes/presence.php

100 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2022-05-21 01:14:50 +02:00
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Copyright (C) 2022 All Rights Reserved.
*/
/**
2022-05-21 01:15:57 +02:00
* presence class
2022-05-21 01:14:50 +02:00
*/
class presence {
/**
* active presence
* @var string $presence_id
*/
public function active($presence_id) {
$json = event_socket::api('show calls as json');
2022-05-21 01:14:50 +02:00
$call_array = json_decode($json, true);
if (isset($call_array['rows'])) {
$x = 0;
foreach ($call_array['rows'] as $row) {
if ($row['presence_id'] == $presence_id) {
return true;
}
if (isset($row['b_presence_id']) && $row['b_presence_id'] != 0) {
if ($row['b_presence_id'] == $presence_id) {
return true;
}
$x++;
}
$x++;
}
}
return false;
}
/**
* show presence
*/
public function show() {
$json = event_socket::api('show calls as json');
2022-05-21 01:14:50 +02:00
$call_array = json_decode($json, true);
if (isset($call_array['rows'])) {
$x = 0;
foreach ($call_array['rows'] as $row) {
$array[$x]['presence_id'] = $row['presence_id'];
$array[$x]['presence_user'] = explode('@', $row['presence_id'])[0];
$array[$x]['domain_name'] = explode('@', $row['presence_id'])[1];
if (isset($row['b_presence_id']) && $row['b_presence_id'] != 0) {
$x++;
$array[$x]['presence_id'] = $row['b_presence_id'];
$array[$x]['presence_user'] = explode('@', $row['b_presence_id'])[0];
$array[$x]['domain_name'] = explode('@', $row['b_presence_id'])[1];
}
$x++;
}
}
return $array;
}
}
//examples
/*
//check if presence is active
$presence_id = '103@'.$_SESSION['domain_name'];
$presence = new presence;
$result = $presence->active($presence_id);
echo "presence_id $presence_id<br />\n";
if ($result) {
echo "active: true\n";
}
else {
Allow namespace in auto loader (#7307) * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove closing tag * remove invalid method params * remove closing tag * remove closing tag * Update auto_loader to load each class file in the project Update the auto_loader class to use an include statement on each file in the project to load the class within the file. This will allow mismatched names within the file to be loaded and mapped according to the declaration instead of the filename. The class is then checked against the parsed classes from the PHP engine so that namespaces are available and mapped to the file they were declared in. An update was also made to the search algorithm used to find a file that was not already loaded by collapsing the array to have only valid matches to increase performance on a cache miss. Logging within the auto_loader has been moved to a function. Multiple files were modified to allow the include statement. When the class has the `if(class_exists())` statement, the auto_loader is called to check for the class. This caused an infinite loop scenario so all wrappers have been removed. The auto_loader will now break the loop by directly modifying the internal classes array instead of trying to restart with the 'reload_classes' method. - APCu is used to cache classes so any loading of the classes is done only once. To clear the APCu cache, restart php-fpm or call the auto_loader::clear_cache() function. - Cache file is used when APCu is not available. To clear the cache remove it from the tmp folder or call the auto_loader::clear_cache() function. - All classes must no longer have a class_exists wrapper to benefit from the performance boost. - Classes should not be directly included when the auto_loader is used. * remove include statement of class file * Update destinations.php
2025-03-12 20:55:47 +01:00
echo "active: false\n";
2022-05-21 01:14:50 +02:00
}
//show active the presence
2024-12-22 18:13:18 +01:00
$presence = new presence;
2022-05-21 01:14:50 +02:00
$array = $presence->show();
*/