Просмотр исходного кода

added acl check for Typespecial search

Piotr Labudda 9 лет назад
Родитель
Сommit
1e26dd75de
2 измененных файлов с 16 добавлено и 6 удалено
  1. 2 2
      SE/se-lib/ACL.php
  2. 14 4
      SE/se-lib/Typespecial.php

+ 2 - 2
SE/se-lib/ACL.php

@@ -386,10 +386,10 @@ SQL;
 	}
 
 	// @params $from - ( ACL | tableName | namespace | etc... - only ACL)
-	public static function query($from) {
+	public static function query($from, $prefix = 't') {
 		Lib::loadClass('AclQueryBuilder');
 		$query = new AclQueryBuilder();
-		$query->from($from);
+		$query->from($from, $prefix);
 		return $query;
 	}
 

+ 14 - 4
SE/se-lib/Typespecial.php

@@ -856,10 +856,20 @@ jQuery('#typeahead-{$fName}').typeahead({
 			}
 		}
 		DBG::log(['msg'=>"this", $this]);
-		// TODO: for all tables filter rows by acl groups
-		// 'tblAliasList' => [
-		//       4095 => 'ADMIN_USERS',
-		//     ),
+		Lib::loadClass('ACL');
+		Lib::loadClass('AclQueryFeatures');
+		$andSql = array_map(
+			function ($tableName, $idTable) {
+				$tableAcl = User::getAcl()->getObjectAcl('default_db', $tableName);
+				return ACL::query($tableAcl, "t_{$idTable}")
+					->where( (new AclQueryFeatures($tableAcl, $params = []))->parseSpecialFilterAccess() )
+					->generateWhereSql()
+				;
+			},
+			$this->tblAliasList, array_keys($this->tblAliasList)
+		);
+		$andSql = array_filter($andSql, ['V', 'filterNotEmpty']);
+		if (!empty($andSql)) $sqlWhereAdd .= "\n" . " and " . implode(" and ", $andSql);
 		$sqlLimit = V::get('limit', 0, $this->sqlQuery, 'int');
 		$sqlLimit = ($sqlLimit > 0) ? $sqlLimit : 20;