From d7b42f4aee68f70b92ee94a56d0deae42996d4d7 Mon Sep 17 00:00:00 2001 From: rldhont Date: Fri, 6 Oct 2023 16:37:35 +0200 Subject: [PATCH] =?UTF-8?q?[PHP]=20Utilisation=20de=20la=20m=C3=A9thode=20?= =?UTF-8?q?de=20projet=20getLoginFilter=20suite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listGeoCommuneDatasource.class.php | 35 +++++++++---------- .../listGeoSectionDatasource.class.php | 33 ++++++++--------- ...istParcelleLieuNoMajicDatasource.class.php | 33 ++++++++--------- .../listParcellePropDatasource.class.php | 35 +++++++++---------- 4 files changed, 62 insertions(+), 74 deletions(-) diff --git a/cadastre/classes/listGeoCommuneDatasource.class.php b/cadastre/classes/listGeoCommuneDatasource.class.php index 3aabf05..1cd14c7 100644 --- a/cadastre/classes/listGeoCommuneDatasource.class.php +++ b/cadastre/classes/listGeoCommuneDatasource.class.php @@ -32,29 +32,26 @@ public function getData($form) $layerConditions = null; $layerSql = cadastreConfig::getLayerSql($repository, $project, $config->commune->id); $polygonFilter = cadastreConfig::getPolygonFilter($repository, $project, $config->commune->id); - if ($layerSql !== null && $polygonFilter !== null) { - $layerConditions .= '(' . $layerSql . ') AND (' . $polygonFilter . ')'; - } elseif ($layerSql !== null) { - $layerConditions = $layerSql; - } elseif ($polygonFilter !== null) { - $layerConditions = $polygonFilter; + $loginFilter = cadastreConfig::getLoginFilter($repository, $project, $config->parcelle->id); + $layerFilters = array(); + if ($layerSql !== null) { + $layerFilters[] = $layerSql; } - $fblConfig = cadastreConfig::getFilterByLogin($repository, $project, $config->commune->id); - - $searchConditions = jDao::createConditions(); - if ($fblConfig !== null) { - $filterValues = array('all'); - if (jAuth::isConnected()) { - if (property_exists($fblConfig, 'filterPrivate') && $fblConfig->filterPrivate == 'True') { - $user = jAuth::getUserSession(); - $filterValues[] = $user->login; - } else { - $filterValues = array_merge($filterValues, jAcl2DbUserGroup::getGroups()); - } + if ($polygonFilter !== null) { + $layerFilters[] = $polygonFilter; + } + if ($loginFilter !== null) { + $layerFilters[] = $loginFilter; + } + if (count($layerFilters) != 0) { + if (count($layerFilters) == 1) { + $layerConditions = $layerFilters[0]; + } else { + $layerConditions = '(' . implode(') AND (', $layerFilters) . ')'; } - $searchConditions->addCondition($fblConfig->filterAttribute, 'IN', $filterValues); } + $searchConditions = jDao::createConditions(); foreach ((array) $this->labelProperty as $property) { $searchConditions->addItemOrder($property, 'asc'); } diff --git a/cadastre/classes/listGeoSectionDatasource.class.php b/cadastre/classes/listGeoSectionDatasource.class.php index 76252fa..505944a 100644 --- a/cadastre/classes/listGeoSectionDatasource.class.php +++ b/cadastre/classes/listGeoSectionDatasource.class.php @@ -42,26 +42,23 @@ public function getData($form) $layerConditions = null; $layerSql = cadastreConfig::getLayerSql($repository, $project, $config->section->id); $polygonFilter = cadastreConfig::getPolygonFilter($repository, $project, $config->section->id); - if ($layerSql !== null && $polygonFilter !== null) { - $layerConditions .= '(' . $layerSql . ') AND (' . $polygonFilter . ')'; - } elseif ($layerSql !== null) { - $layerConditions = $layerSql; - } elseif ($polygonFilter !== null) { - $layerConditions = $polygonFilter; + $loginFilter = cadastreConfig::getLoginFilter($repository, $project, $config->parcelle->id); + $layerFilters = array(); + if ($layerSql !== null) { + $layerFilters[] = $layerSql; } - $fblConfig = cadastreConfig::getFilterByLogin($repository, $project, $config->section->id); - - if ($fblConfig !== null) { - $filterValues = array('all'); - if (jAuth::isConnected()) { - if (property_exists($fblConfig, 'filterPrivate') && $fblConfig->filterPrivate == 'True') { - $user = jAuth::getUserSession(); - $filterValues[] = $user->login; - } else { - $filterValues = array_merge($filterValues, jAcl2DbUserGroup::getGroups()); - } + if ($polygonFilter !== null) { + $layerFilters[] = $polygonFilter; + } + if ($loginFilter !== null) { + $layerFilters[] = $loginFilter; + } + if (count($layerFilters) != 0) { + if (count($layerFilters) == 1) { + $layerConditions = $layerFilters[0]; + } else { + $layerConditions = '(' . implode(') AND (', $layerFilters) . ')'; } - $searchConditions->addCondition($fblConfig->filterAttribute, 'IN', $filterValues); } foreach ((array) $this->labelProperty as $property) { diff --git a/cadastre/classes/listParcelleLieuNoMajicDatasource.class.php b/cadastre/classes/listParcelleLieuNoMajicDatasource.class.php index de2d1fb..c447047 100644 --- a/cadastre/classes/listParcelleLieuNoMajicDatasource.class.php +++ b/cadastre/classes/listParcelleLieuNoMajicDatasource.class.php @@ -42,26 +42,23 @@ public function getData($form) $layerConditions = null; $layerSql = cadastreConfig::getLayerSql($repository, $project, $config->parcelle->id); $polygonFilter = cadastreConfig::getPolygonFilter($repository, $project, $config->parcelle->id); - if ($layerSql !== null && $polygonFilter !== null) { - $layerConditions .= '(' . $layerSql . ') AND (' . $polygonFilter . ')'; - } elseif ($layerSql !== null) { - $layerConditions = $layerSql; - } elseif ($polygonFilter !== null) { - $layerConditions = $polygonFilter; + $loginFilter = cadastreConfig::getLoginFilter($repository, $project, $config->parcelle->id); + $layerFilters = array(); + if ($layerSql !== null) { + $layerFilters[] = $layerSql; } - $fblConfig = cadastreConfig::getFilterByLogin($repository, $project, $config->parcelle->id); - - if ($fblConfig !== null) { - $filterValues = array('all'); - if (jAuth::isConnected()) { - if (property_exists($fblConfig, 'filterPrivate') && $fblConfig->filterPrivate == 'True') { - $user = jAuth::getUserSession(); - $filterValues[] = $user->login; - } else { - $filterValues = array_merge($filterValues, jAcl2DbUserGroup::getGroups()); - } + if ($polygonFilter !== null) { + $layerFilters[] = $polygonFilter; + } + if ($loginFilter !== null) { + $layerFilters[] = $loginFilter; + } + if (count($layerFilters) != 0) { + if (count($layerFilters) == 1) { + $layerConditions = $layerFilters[0]; + } else { + $layerConditions = '(' . implode(') AND (', $layerFilters) . ')'; } - $searchConditions->addCondition($fblConfig->filterAttribute, 'IN', $filterValues); } foreach ((array) $this->labelProperty as $property) { diff --git a/cadastre/classes/listParcellePropDatasource.class.php b/cadastre/classes/listParcellePropDatasource.class.php index cad3e67..bfbd4de 100644 --- a/cadastre/classes/listParcellePropDatasource.class.php +++ b/cadastre/classes/listParcellePropDatasource.class.php @@ -57,26 +57,23 @@ public function getData($form) $layerConditions = null; $layerSql = cadastreConfig::getLayerSql($repository, $project, $config->parcelle->id); $polygonFilter = cadastreConfig::getPolygonFilter($repository, $project, $config->parcelle->id); - if ($layerSql !== null && $polygonFilter !== null) { - $layerConditions .= '(' . $layerSql . ') AND (' . $polygonFilter . ')'; - } elseif ($layerSql !== null) { - $layerConditions = $layerSql; - } elseif ($polygonFilter !== null) { - $layerConditions = $polygonFilter; - } - $fblConfig = cadastreConfig::getFilterByLogin($repository, $project, $config->parcelle->id); - - if ($fblConfig !== null) { - $filterValues = array('all'); - if (jAuth::isConnected()) { - if (property_exists($fblConfig, 'filterPrivate') && $fblConfig->filterPrivate == 'True') { - $user = jAuth::getUserSession(); - $filterValues[] = $user->login; - } else { - $filterValues = array_merge($filterValues, jAcl2DbUserGroup::getGroups()); - } + $loginFilter = cadastreConfig::getLoginFilter($repository, $project, $config->parcelle->id); + $layerFilters = array(); + if ($layerSql !== null) { + $layerFilters[] = $layerSql; + } + if ($polygonFilter !== null) { + $layerFilters[] = $polygonFilter; + } + if ($loginFilter !== null) { + $layerFilters[] = $loginFilter; + } + if (count($layerFilters) != 0) { + if (count($layerFilters) == 1) { + $layerConditions = $layerFilters[0]; + } else { + $layerConditions = '(' . implode(') AND (', $layerFilters) . ')'; } - $searchConditions->addCondition($fblConfig->filterAttribute, 'IN', $filterValues); } foreach ((array) $this->labelProperty as $property) {