mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Added method to get number of accounts
This commit is contained in:
parent
03d3037398
commit
19a7ca05f5
3 changed files with 26 additions and 0 deletions
|
|
@ -210,6 +210,18 @@ class Account {
|
|||
return false;
|
||||
}
|
||||
|
||||
function getCount() {
|
||||
$query = "SELECT count(*) FROM " . ACCOUNTS_DB_TABLE;
|
||||
$stmt = $this->conn->prepare($query);
|
||||
Logger::getInstance()->debug("GetCount " . (string)$this);
|
||||
if ($stmt->execute()) {
|
||||
$number_of_rows = $stmt->fetchColumn();
|
||||
return $number_of_rows;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return -1;
|
||||
}
|
||||
|
||||
function getAll() {
|
||||
$query = "SELECT ac.id, ac.username, ac.domain, ac.activated, ac.confirmation_key, ac.email, al.alias FROM " . ACCOUNTS_DB_TABLE .
|
||||
" ac LEFT JOIN " . ALIAS_DB_TABLE . " al ON ac.id = al.account_id";
|
||||
|
|
|
|||
|
|
@ -965,6 +965,16 @@ function xmlrpc_delete_email_account($method, $args) {
|
|||
return NOK;
|
||||
}
|
||||
|
||||
// args = []
|
||||
function xmlrpc_get_accounts_count($method, $args) {
|
||||
Logger::getInstance()->message("[XMLRPC] xmlrpc_get_accounts_count()");
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
$account = new Account($db);
|
||||
return $account->getCount();
|
||||
}
|
||||
|
||||
function xmlrpc_accounts_register_methods($server) {
|
||||
if (ALLOW_TEST_ACCOUNTS) {
|
||||
// /!\ This methods must be used for tests purposes only /!\
|
||||
|
|
@ -992,6 +1002,8 @@ function xmlrpc_accounts_register_methods($server) {
|
|||
xmlrpc_server_register_method($server, 'update_password', 'xmlrpc_update_password');// args = [username, old password, new password, [domain], [algo]], return OK
|
||||
xmlrpc_server_register_method($server, 'update_hash', 'xmlrpc_update_hash');// args = [username, old hash, new hash, [domain], [algo]], return OK
|
||||
xmlrpc_server_register_method($server, 'update_email', 'xmlrpc_update_email');// args = [username, password, new email, [domain], [algo]], return OK
|
||||
|
||||
xmlrpc_server_register_method($server, 'get_accounts_count', 'xmlrpc_get_accounts_count');//args = []
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ if (USE_DIGEST_AUTH) {
|
|||
// compatibility
|
||||
13 => 'create_account',
|
||||
14 => 'create_account_with_useragent',
|
||||
|
||||
15 => 'get_accounts_count',
|
||||
);
|
||||
|
||||
// Get authentication header if there is one
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue