Browse Source

added filter by link field in UserUrlAction storage acl

Piotr Labudda 8 years ago
parent
commit
3e7a315dbf
1 changed files with 14 additions and 4 deletions
  1. 14 4
      SE/se-lib/Schema/UserUrlActionStorageAcl.php

+ 14 - 4
SE/se-lib/Schema/UserUrlActionStorageAcl.php

@@ -107,9 +107,20 @@ class Schema_UserUrlActionStorageAcl extends Core_AclSimpleSchemaBase {
   }
 
   public function _parseSqlWhere($params = []) {
-    $sqlWhereAnd = "";
+    $sqlWhereAnd = [];
     // TODO: parse where/ogc, etc.
-    return $sqlWhereAnd;
+    if (!empty($params)) DBG::log($params, 'array', "\$params");
+    if (!empty($params['f_link'])) {
+      if (is_string($params['f_link'])) {
+        if ('=' === substr($params['f_link'], 0, 1)) {
+          $sqlWhereAnd[] = "t.link = " . DB::getPDO()->quote(substr($params['f_link'], 1));
+        } else {
+          $sqlWhereAnd[] = "t.link like " . DB::getPDO()->quote("%{$params['f_link']}%");
+        }
+      }
+    }
+    if (!empty($params)) DBG::log($sqlWhereAnd, 'array', "\$sqlWhereAnd");
+    return (!empty($sqlWhereAnd)) ? "where " . implode(" and ", $sqlWhereAnd) : "";
   }
 
   public function getItems($params = []) {
@@ -178,8 +189,7 @@ class Schema_UserUrlActionStorageAcl extends Core_AclSimpleSchemaBase {
         where c.ID_USER = {$this->idUser}
           {$sqlWhereAndIdProces}
       ) as t
-      where 1=1
-        {$sqlWhereAnd}
+      {$sqlWhereAnd}
       {$sqlOrderBy}
       {$sqlLimitOffset}
     ", 'ID_URL');