Skip to content

Commit ecf891a

Browse files
author
nveid
committed
Added remoting API call: client_get_all
@param -> session_id @return -> Array of all Client IDs on server
1 parent 4d7cbc6 commit ecf891a

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

interface/lib/classes/remoting.inc.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,14 +2325,19 @@ protected function deleteQuery($formdef_file, $primary_id, $event_identifier = '
23252325

23262326
protected function checkPerm($session_id, $function_name)
23272327
{
2328+
global $app;
23282329
$dobre=array();
23292330
$session = $this->getSession($session_id);
23302331
if(!$session){
23312332
return false;
23322333
}
23332334

23342335
$dobre= str_replace(';',',',$session['remote_functions']);
2335-
return in_array($function_name, explode(',', $dobre) );
2336+
$check = in_array($function_name, explode(',', $dobre) );
2337+
if(!$check) {
2338+
$app->log("REMOTE-LIB DENY: ".$session_id ." /". $function_name, LOGLEVEL_WARN);
2339+
}
2340+
return $check;
23362341
}
23372342

23382343

@@ -2445,6 +2450,26 @@ public function client_get_by_username($session_id, $username) {
24452450
return false;
24462451
}
24472452
}
2453+
/**
2454+
* Get All client_id's from database
2455+
* @param int session_id
2456+
* @return Array of all client_id's
2457+
*/
2458+
public function client_get_all($session_id) {
2459+
global $app;
2460+
if(!$this->checkPerm($session_id, 'client_get_all')) {
2461+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
2462+
return false;
2463+
}
2464+
$result = $app->db->queryAllRecords("SELECT client_id FROM client WHERE 1");
2465+
if(!$result) {
2466+
return false;
2467+
}
2468+
foreach( $result as $record) {
2469+
$rarrary[] = $record['client_id'];
2470+
}
2471+
return $rarrary;
2472+
}
24482473

24492474
/**
24502475
* Changes client password
@@ -2954,4 +2979,4 @@ public function openvz_vm_delete($session_id, $vm_id)
29542979

29552980

29562981
}
2957-
?>
2982+
?>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

3-
$function_list['client_get,client_add,client_update,client_delete,client_get_sites_by_user,client_get_by_username,client_change_password,client_get_id,client_delete_everything'] = 'Client functions';
3+
$function_list['client_get_all,client_get,client_add,client_update,client_delete,client_get_sites_by_user,client_get_by_username,client_change_password,client_get_id,client_delete_everything'] = 'Client functions';
44

5-
?>
5+
?>

0 commit comments

Comments
 (0)