瀏覽代碼

added support to minInclusive restriction in RefConfig and InstanceView

Piotr Labudda 8 年之前
父節點
當前提交
9424598f8a
共有 2 個文件被更改,包括 11 次插入3 次删除
  1. 6 2
      SE/se-lib/InstanceConfig.php
  2. 5 1
      SE/se-lib/RefConfig.php

+ 6 - 2
SE/se-lib/InstanceConfig.php

@@ -101,8 +101,8 @@ class InstanceConfig {
 		$idInstance = $conf->id;
 		$idInstance = $conf->id;
 		$dbName = DB::getPDO()->getDatabaseName();
 		$dbName = DB::getPDO()->getDatabaseName();
 		$sqlIsInstanceView = self::generateIsInstanceView($objectItem['namespace'], $objectItem, $conf);
 		$sqlIsInstanceView = self::generateIsInstanceView($objectItem['namespace'], $objectItem, $conf);
-		DB::getPDO()->execSql(" DROP VIEW IF EXISTS `{$dbName}`.`CRM__#INSTANCE_TABLE__{$idInstance}_VIEW` ");
-		DB::getPDO()->execSql(" CREATE VIEW `{$dbName}`.`CRM__#INSTANCE_TABLE__{$idInstance}_VIEW` AS {$sqlIsInstanceView} ");
+		$instanceViewTableName = "CRM__#INSTANCE_TABLE__{$idInstance}_VIEW";
+		DB::getPDO()->execSql(" CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `{$dbName}`.`{$instanceViewTableName}` AS {$sqlIsInstanceView} ");
 	}
 	}
 
 
 	static function getRootNamespace($namespace) { // TODO: works only for relative urls! - mv to Acl->getRootNamespace
 	static function getRootNamespace($namespace) { // TODO: works only for relative urls! - mv to Acl->getRootNamespace
@@ -173,6 +173,10 @@ class InstanceConfig {
 							:	DB::getPDO()->quote($option);
 							:	DB::getPDO()->quote($option);
 						}, array_keys($xsdRestriction['enumeration']))) . ")";
 						}, array_keys($xsdRestriction['enumeration']))) . ")";
 					}
 					}
+					if (array_key_exists('minInclusive', $xsdRestriction)) {
+						$minInclusive = (int)$xsdRestriction['minInclusive'];
+						$sqlRestrictions[] = "{$sqlTablePrefix}.`{$fieldName}` > {$minInclusive}";
+					}
 				}
 				}
 				return $sqlRestrictions;
 				return $sqlRestrictions;
 			}, array_keys($fieldsWithRestrictions), array_values($fieldsWithRestrictions)),
 			}, array_keys($fieldsWithRestrictions), array_values($fieldsWithRestrictions)),

+ 5 - 1
SE/se-lib/RefConfig.php

@@ -385,6 +385,10 @@ class RefConfig {
 									:	DB::getPDO()->quote($option);
 									:	DB::getPDO()->quote($option);
 								}, array_keys($restrictions['enumeration']))) . ")";
 								}, array_keys($restrictions['enumeration']))) . ")";
 							}
 							}
+							if (array_key_exists('minInclusive', $restrictions)) {
+								$minInclusive = (int)$restrictions['minInclusive'];
+								$sqlRestrictions[] = "{$sqlTablePrefix}.`{$field['fieldNamespace']}` > {$minInclusive}";
+							}
 						}
 						}
 						return $sqlRestrictions;
 						return $sqlRestrictions;
 					}, $rootLocalFieldsWithRestrictions),
 					}, $rootLocalFieldsWithRestrictions),
@@ -419,7 +423,7 @@ class RefConfig {
 				);
 				);
 			}
 			}
 		}
 		}
-		$sqlWhereFromRestrictions = (!empty($sqlWhereFromRestrictions)) ? implode(" and ", $sqlWhereFromRestrictions) : "1=1";
+		$sqlWhereFromRestrictions = (!empty($sqlWhereFromRestrictions)) ? implode("\n\t and ", $sqlWhereFromRestrictions) : "1=1";
 		$sqlChildFieldName = $childAcl->getSqlFieldName($appInfoRootFieldName);
 		$sqlChildFieldName = $childAcl->getSqlFieldName($appInfoRootFieldName);
 		$sql = "
 		$sql = "
 			select root.{$rootPrimaryKeyField} as PRIMARY_KEY
 			select root.{$rootPrimaryKeyField} as PRIMARY_KEY