瀏覽代碼

added local_ref test in wfs

Piotr Labudda 9 年之前
父節點
當前提交
133c2afcdd
共有 4 個文件被更改,包括 58 次插入3 次删除
  1. 1 1
      SE/se-lib/Api/WfsLogger.php
  2. 37 0
      SE/se-lib/Api/WfsServerBase.php
  3. 1 0
      SE/se-lib/Core/AclBase.php
  4. 19 2
      SE/se-lib/TestPermsStorageAcl.php

+ 1 - 1
SE/se-lib/Api/WfsLogger.php

@@ -6,7 +6,7 @@ class Api_WfsLogger {
 	protected $_logFile;
 	protected $_logFile;
 
 
 	public function __construct() {
 	public function __construct() {
-		$this->_logFile = "/tmp/wfs.log";
+		$this->_logFile = ('production' == V::get('P5_ENV', 'production', $_SERVER)) ? "/tmp/wfs.log" : "/tmp/wfs-dev.log";
 		if (!is_writable($this->_logFile)) {
 		if (!is_writable($this->_logFile)) {
 			$fp = @fopen($this->_logFile, "w");
 			$fp = @fopen($this->_logFile, "w");
 			if ($fp === false) return;
 			if ($fp === false) return;

+ 37 - 0
SE/se-lib/Api/WfsServerBase.php

@@ -1691,6 +1691,8 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 				}
 				}
 				if ('ref:' == substr($fldType, 0, 4)) {
 				if ('ref:' == substr($fldType, 0, 4)) {
 					$elNode->setAttribute('ref', substr($fldType, 4));
 					$elNode->setAttribute('ref', substr($fldType, 4));
+				} else if ('local_ref:' == substr($fldType, 0, 10)) {
+					$elNode->setAttribute('type', "{$fldName}Type");
 				} else {
 				} else {
 					$elNode->setAttribute('name', $fldName);
 					$elNode->setAttribute('name', $fldName);
 					$elNode->setAttribute('type', $fldType);
 					$elNode->setAttribute('type', $fldType);
@@ -1719,6 +1721,41 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 				$elNode->setAttribute('substitutionGroup', 'gml:AbstractFeature');
 				$elNode->setAttribute('substitutionGroup', 'gml:AbstractFeature');
 			}
 			}
 
 
+			foreach ($fldList as $idZasob => $fldName) {
+				$fldType = $acl->getXsdFieldType($fldName);
+				if ('local_ref:' == substr($fldType, 0, 10)) {
+					$localRefType = substr($fldType, 10);
+					// <xsd:complexType name="produkt_Type">
+					// 	<xsd:sequence>
+					// 		<xsd:element name="idProd" type="xsd:integer" />
+					// 		<xsd:element name="nazwa" type="xsd:string" />
+					// 		<xsd:element name="cena" type="xsd:decimal" />
+					// 	</xsd:sequence>
+					// </xsd:complexType>
+					$ctNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType');
+					$rootNode->appendChild($ctNode);
+					$ctNode->setAttribute('name', "{$fldName}Type");
+
+					$seqNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:sequence');
+					$ctNode->appendChild($seqNode);
+
+					$elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
+					$seqNode->appendChild($elNode);
+					$elNode->setAttribute('name', "test_id");
+					$elNode->setAttribute('type', "xsd:integer");
+
+					$elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
+					$seqNode->appendChild($elNode);
+					$elNode->setAttribute('name', "test_opis");
+					$elNode->setAttribute('type', "xsd:string");
+
+					$elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
+					$seqNode->appendChild($elNode);
+					$elNode->setAttribute('name', "test_decimal");
+					$elNode->setAttribute('type', "xsd:decimal");
+				}
+			}
+
 			if (!$simple) {
 			if (!$simple) {
 				foreach ($fldList as $fldName) {
 				foreach ($fldList as $fldName) {
 					if ($acl->isEnumerationField($fldName)) {
 					if ($acl->isEnumerationField($fldName)) {

+ 1 - 0
SE/se-lib/Core/AclBase.php

@@ -24,6 +24,7 @@ class Core_AclBase {
   public function isTextField($fldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isTextField($fldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isBinaryField($fieldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isBinaryField($fieldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isEnumerationField($fldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isEnumerationField($fldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
+  public function getEnumerations($fldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function getFieldType($colName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function getFieldType($colName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isAllowed($idZasob, $taskPerm, $record = null) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function isAllowed($idZasob, $taskPerm, $record = null) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function hasFieldPerm($idZasob, $taskPerm) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function hasFieldPerm($idZasob, $taskPerm) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }

+ 19 - 2
SE/se-lib/TestPermsStorageAcl.php

@@ -17,6 +17,7 @@ class TestPermsStorageAcl extends Core_AclBase {
   public function getRealFieldListByIdZasob($force = false) {
   public function getRealFieldListByIdZasob($force = false) {
     $cols = $this->parentAcl->getRealFieldListByIdZasob();
     $cols = $this->parentAcl->getRealFieldListByIdZasob();
     $cols[100000] = 'File';
     $cols[100000] = 'File';
+    // $cols[100001] = 'NestedObjectTest';
     return $cols;
     return $cols;
   }
   }
   public function getFieldIdByName($fieldName) {
   public function getFieldIdByName($fieldName) {
@@ -98,18 +99,34 @@ class TestPermsStorageAcl extends Core_AclBase {
     // if (!$acl->hasFieldPerm($idZasob, 'R')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_read", "false");
     // if (!$acl->hasFieldPerm($idZasob, 'R')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_read", "false");
 		return $attributes;
 		return $attributes;
 	}
 	}
-  public function isEnumerationField($fieldName) { return false; }
+  public function isEnumerationField($fieldName) {
+    if ('A_STATUS' == $fieldName) return true;
+    return false;
+  }
+  public function getEnumerations($fieldName) {
+    if ('A_STATUS' == $fieldName) return $this->parentAcl->getEnumerations($fieldName);
+    return null;
+  }
   public function validateFieldAction($fieldName, $taskPerm, $record = null) {
   public function validateFieldAction($fieldName, $taskPerm, $record = null) {
     if ('File' == $fieldName) {
     if ('File' == $fieldName) {
       // return 'ref:p5_objects:File';
       // return 'ref:p5_objects:File';
       return true;
       return true;
     }
     }
+    // if ('NestedObjectTest' == $fieldName) {
+    //   // return 'ref:p5_objects:NestedObjectTest';
+    //   return true;
+    // }
 		return $this->parentAcl->isAllowed($fieldID = $this->parentAcl->getFieldIdByName($fieldName), $taskPerm, $record);
 		return $this->parentAcl->isAllowed($fieldID = $this->parentAcl->getFieldIdByName($fieldName), $taskPerm, $record);
 	}
 	}
   public function getXsdFieldType($fieldName) {
   public function getXsdFieldType($fieldName) {
     if ('File' == $fieldName) return 'ref:p5_objects:File';
     if ('File' == $fieldName) return 'ref:p5_objects:File';
+    // if ('NestedObjectTest' == $fieldName) return 'local_ref:p5_objects:NestedObjectTest';
     return $this->parentAcl->getXsdFieldType($fieldName);
     return $this->parentAcl->getXsdFieldType($fieldName);
   }
   }
-  public function isGeomField($fldName) { return $this->parentAcl->isGeomField($fldName); }
+  public function isGeomField($fldName) {
+    if ('File' == $fieldName) return false;
+    // if ('NestedObjectTest' == $fieldName) return false;
+    return $this->parentAcl->isGeomField($fldName);
+  }
 
 
 }
 }