Added permissions to internal BuildingApi
This commit is contained in:
@@ -372,8 +372,27 @@ class BuildingController extends mfBaseController {
|
||||
|
||||
private function getFilteredBuildingsApi() {
|
||||
$buildings = [];
|
||||
$filter = $this->request->filter;
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
}
|
||||
|
||||
if(!$this->me->is("Admin")) {
|
||||
$my_networks = $this->me->myNetworks(['netowner','salespartner']);
|
||||
|
||||
$network_ids = [];
|
||||
foreach($my_networks as $net) {
|
||||
$network_ids[] = $net->id;
|
||||
}
|
||||
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
if(!in_array($filter['network_id'], $network_ids)) {
|
||||
$filter['network_id'] = $network_ids;
|
||||
}
|
||||
} else {
|
||||
$filter['network_id'] = $network_ids;
|
||||
}
|
||||
}
|
||||
|
||||
$results = BuildingModel::search($filter);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class BuildingModel {
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
@@ -105,7 +105,7 @@ class BuildingModel {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
public static function search($filter=[], $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user