Ver código fonte

fixed acl query features, added custom block filter

Piotr Labudda 9 anos atrás
pai
commit
2beeeefbd3
1 arquivos alterados com 16 adições e 6 exclusões
  1. 16 6
      SE/se-lib/AclQueryFeatures.php

+ 16 - 6
SE/se-lib/AclQueryFeatures.php

@@ -247,7 +247,7 @@ class AclQueryFeatures {
     $parser = new ParseOgcFilter();
     $parser = new ParseOgcFilter();
     $parser->loadOgcFilter($ogcFilter);
     $parser->loadOgcFilter($ogcFilter);
     $queryWhereBuilder = $parser->convertToSqlQueryWhereBuilder();
     $queryWhereBuilder = $parser->convertToSqlQueryWhereBuilder();
-    return $queryWhereBuilder->getQueryWhere($this->_fromPrefix);
+    return $queryWhereBuilder->getQueryWhere('t'); // TODO: $this->_fromPrefix
   }
   }
 
 
   public function getQuery() {
   public function getQuery() {
@@ -260,15 +260,19 @@ class AclQueryFeatures {
       ->isNotInstance($filtrIsNotInstance);
       ->isNotInstance($filtrIsNotInstance);
     // ->join($instanceTable, 'i', [ 'rawJoin' => "i.pk = t.{$sqlPrimaryKey} and i.idInstance = {$idInstance}" ])
     // ->join($instanceTable, 'i', [ 'rawJoin' => "i.pk = t.{$sqlPrimaryKey} and i.idInstance = {$idInstance}" ])
     // $this->_query->where($ds->_parseSqlWhere($params))
     // $this->_query->where($ds->_parseSqlWhere($params))
-    DBG::log($this->_params, 'array', "\$this->_params");
+    DBG::log($this->_params, 'array', "AclQueryFeatures::getQuery \$this->_params");
     foreach ($this->_params as $k => $v) {
     foreach ($this->_params as $k => $v) {
-      if ('f_' === substr($k, 0, 2) && strlen($k) > 3) {
+      // DBG::log(['v'=>$v, 'is_numeric' => is_numeric($k), 'is_int' => is_int($k), 'is_array' => is_array($v)], 'array', "AclQueryFeatures::getQuery \$this->_params[{$k}]");
+      if (is_int($k) && is_array($v)) {
+        $this->_query->where($v); // TODO: check format [$fieldName, $comparisonSign, $value]
+      } else if (is_int($k) && null === $v) { // skip NULL
+      } else if ('f_' === substr($k, 0, 2) && is_string($v) && strlen($k) > 3) {
         $fieldName = substr($k, 2);
         $fieldName = substr($k, 2);
         $fieldType = $this->_acl->getXsdFieldType($fieldName);
         $fieldType = $this->_acl->getXsdFieldType($fieldName);
         list($comparisonSign, $value) = $this->parseQueryValue($fieldName, $v, $fieldType);
         list($comparisonSign, $value) = $this->parseQueryValue($fieldName, $v, $fieldType);
         DBG::log([ $fieldName, $comparisonSign, $value, $fieldType ], 'array', "parseQueryValue");
         DBG::log([ $fieldName, $comparisonSign, $value, $fieldType ], 'array', "parseQueryValue");
         $this->_query->where([$fieldName, $comparisonSign, $value]);
         $this->_query->where([$fieldName, $comparisonSign, $value]);
-      } else if ('sf_' === substr($k, 0, 3) && strlen($k) > 4) {
+      } else if ('sf_' === substr($k, 0, 3) && is_string($v) && strlen($k) > 4) {
         switch (substr($k, 3)) {
         switch (substr($k, 3)) {
           case 'Msgs': $this->_query->where($this->parseSpecialFilterMsgs($v)); break;
           case 'Msgs': $this->_query->where($this->parseSpecialFilterMsgs($v)); break;
           case 'Problemy': $this->_query->where($this->parseSpecialFilterProblemy($v)); break;
           case 'Problemy': $this->_query->where($this->parseSpecialFilterProblemy($v)); break;
@@ -277,14 +281,20 @@ class AclQueryFeatures {
           case 'Access': break; // SKIP - used below
           case 'Access': break; // SKIP - used below
           default: throw new Exception("Not Implemented special filter '".substr($k, 3)."'");
           default: throw new Exception("Not Implemented special filter '".substr($k, 3)."'");
         }
         }
-      } else if ('ogc:Filter' == $k) {
+      } else if ('ogc:Filter' === $k) {
         $this->_query->where($this->parseOgcFilter($v));
         $this->_query->where($this->parseOgcFilter($v));
-      } else if ('primaryKey' == $k) {
+      } else if ('primaryKey' === $k) {
         $fieldName = $this->_acl->getPrimaryKeyField();
         $fieldName = $this->_acl->getPrimaryKeyField();
         $fieldType = $this->_acl->getXsdFieldType($fieldName);
         $fieldType = $this->_acl->getXsdFieldType($fieldName);
         list($comparisonSign, $value) = $this->parseQueryValue($fieldName, $v, $fieldType);
         list($comparisonSign, $value) = $this->parseQueryValue($fieldName, $v, $fieldType);
         DBG::log([ $fieldName, $comparisonSign, $value, $fieldType ], 'array', "parseQueryValue");
         DBG::log([ $fieldName, $comparisonSign, $value, $fieldType ], 'array', "parseQueryValue");
         $this->_query->where([$fieldName, $comparisonSign, $value]);
         $this->_query->where([$fieldName, $comparisonSign, $value]);
+      } else if ('limit' === $k) {
+      } else if ('limitstart' === $k) {
+      } else if ('order_by' === $k) {
+      } else if ('order_dir' === $k) {
+      } else {
+        throw new Exception("Not Implemented param '{$k}' = '{$v}'");
       }
       }
     }
     }