Skip to content

Commit

Permalink
[PHP] Utilisation de la méthode de projet getLoginFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Oct 12, 2023
1 parent 8ced78f commit 828b6b8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
21 changes: 21 additions & 0 deletions cadastre/classes/cadastreConfig.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ public static function getFilterByLogin($repository, $project, $layerId)
return $loginFilterConfig;
}

public static function getLoginFilter($repository, $project, $layerId)
{
if (jAuth::isConnected() && jAcl2::check('lizmap.tools.loginFilteredLayers.override', $repository)) {
return null;
}

$p = lizmap::getProject($repository . '~' . $project);

$qgisLayer = $p->getLayer($layerId);
if (!$qgisLayer) {
return null;
}

$loginFilterObj = $p->getLoginFilter($qgisLayer->getName());
if (!empty($loginFilterObj) && array_key_exists('filter', $loginFilterObj)) {
return $loginFilterObj['filter'];
}

return null;
}

public static function getPolygonFilter($repository, $project, $layerId)
{
if (jAuth::isConnected() && jAcl2::check('lizmap.tools.loginFilteredLayers.override', $repository)) {
Expand Down
33 changes: 15 additions & 18 deletions cadastre/classes/listParcelleLieuDatasource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,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) {
Expand Down

0 comments on commit 828b6b8

Please sign in to comment.