Commit 19a7ca05 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added method to get number of accounts

parent 03d30373
Pipeline #7410 passed with stage
in 14 seconds
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment