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

fixed bug missing map editor - fixed check for geom field in Acl

Piotr Labudda 9 лет назад
Родитель
Сommit
10fc150fe1
4 измененных файлов с 31 добавлено и 38 удалено
  1. 0 6
      SE/se-lib/Core/AclBase.php
  2. 21 0
      SE/se-lib/Core/AclHelper.php
  3. 2 10
      SE/se-lib/TableAcl.php
  4. 8 22
      SE/se-lib/TableAjax.php

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

@@ -59,12 +59,6 @@ class Core_AclBase {
   public function canReadObjectField($fieldName, $record) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function canWriteField($fieldName) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
   public function canWriteObjectField($fieldName, $record) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
-  public function hasCreatePerms() {
-		foreach ($this->getFieldListByIdZasob() as $fieldName) {// TODO: use getFieldList
-			if ($this->canCreateField($fieldName)) return true;
-		}
-		return false;
-	}
 
   public function getRawLabel($posLimit = 20) { return substr($this->getName(), 0, $posLimit); }
 

+ 21 - 0
SE/se-lib/Core/AclHelper.php

@@ -0,0 +1,21 @@
+<?php
+
+class Core_AclHelper {// Helper class for Acl
+
+  public static function hasCreatePerms($acl) {
+    foreach ($acl->getFieldListByIdZasob() as $fieldName) {// TODO: use getFieldList
+      // echo"<p>\$acl->canCreateField({$fieldName}): (".$acl->canCreateField($fieldName).")</p>";
+      if ($acl->canCreateField($fieldName)) return true;
+    }
+    return false;
+  }
+
+  public static function hasGeomFields($acl) {
+    foreach ($acl->getFieldListByIdZasob() as $fieldName) {
+      // echo"<p>\$acl->isGeomField({$fieldName}): (".$acl->isGeomField($fieldName).") \$acl->canReadField({$fieldName}): (".$acl->canReadField($fieldName).")</p>";
+      if ($acl->isGeomField($fieldName) && $acl->canReadField($fieldName)) return true;
+    }
+    return false;
+  }
+
+}

+ 2 - 10
SE/se-lib/TableAcl.php

@@ -200,13 +200,6 @@ class TableAcl extends Core_AclBase {
 		return false;
 	}
 
-	public function hasCreatePerms() {
-		foreach ($this->_fields as $kFldID => $vFld) {
-			if ($this->hasFieldPerm($kFldID, 'C')) return true;
-		}
-		return false;
-	}
-
 	public function hasSuperAccessPerms() {
 		foreach ($this->_fields as $kFldID => $vFld) {
 			if ($this->hasFieldPerm($kFldID, 'S')) {
@@ -360,9 +353,8 @@ class TableAcl extends Core_AclBase {
 		if ('A_RECORD_CREATE_AUTHOR' == $fieldName) return true;
 		if ('A_RECORD_UPDATE_DATE' == $fieldName) return true;
 		if ('A_RECORD_UPDATE_AUTHOR' == $fieldName) return true;
-		if (!$this->hasFieldPerm($idZasob, $taskPerm = 'R')) {
-			if ($this->hasFieldPerm($idZasob, 'V')) return true;
-		}
+		if ($this->hasFieldPerm($idZasob, $taskPerm = 'R')) return true;
+		if ($this->hasFieldPerm($idZasob, $taskPerm = 'V')) return true;
 		return false;
 	}
   public function canReadObjectField($fieldName, $record) {

+ 8 - 22
SE/se-lib/TableAjax.php

@@ -10,6 +10,7 @@ Lib::loadClass('UserProfile');
 Lib::loadClass('ProcesHelper');
 Lib::loadClass('Router');
 Lib::loadClass('Route_UrlAction');
+Lib::loadClass('Core_AclHelper');
 
 // TODO: change all links: MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={idZasob} to _route=ViewTableAjax&typeName=p5_default_db:{tableName}
 
@@ -226,27 +227,11 @@ class TableAjax extends ViewAjax {
 		return false;
 	}
 
-	public function hasGeomFields() {
-		$hasGeomFields = false;
-		$fieldsList = $this->_acl->getFieldListByIdZasob();
-		foreach ($fieldsList as $kID => $fieldName) {
-			if ($this->_acl->isGeomField($fieldName) && $this->_acl->canReadField($fieldName)) {
-				$hasGeomFields = true;
-				break;
-			}
-		}
-		return $hasGeomFields;
-	}
-
 	public function render() {
-		$hasGeomFlds = $this->hasGeomFields();
-
-		$tblAjaxMap = null;
-		if ($hasGeomFlds) {
-			$tblAjaxMap = new TableAjaxMap($this->_acl, 512, 400);
-		}
-
-		$hasPermCreate = $this->_acl->hasCreatePerms();
+		$acl = $this->_acl;
+		$hasGeomFlds = Core_AclHelper::hasGeomFields($acl);
+		$tblAjaxMap = ($hasGeomFlds) ? new TableAjaxMap($acl, 512, 400) : null;
+		$hasPermCreate = Core_AclHelper::hasCreatePerms($acl);
 
 		$jsToogleFiltrProcesuFunctionName = 'tableAjaxToggleFiltrProcesInit';
 		ob_start();
@@ -1386,7 +1371,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 			// currentNode.find('i').tooltip('hide');
 			node = $('<tr class="sort ' + nodeClass + '"></tr>');
 			//create the functions column
-			if (priv.options.rowFunctions || priv.options.filtersClean) {
+			if (priv.options.tblFunctions || priv.options.filtersClean) {
 				var headCell = $('<th class="text-right head-info stickyCol1"></th>').appendTo(node);
 				$.map(priv.options.tblFunctions, function(funObj, funName){
 					var funHtml = $('<a></a>');
@@ -4554,10 +4539,11 @@ jQuery(document).ready(function(){
 	}
 
 	private function sendAjaxCreate($args) {
+		$acl = $this->_acl;
 		header("Content-type: text/plain");
 		$DBG = ('1' == V::get('DBG', '', $_REQUEST));
 
-		if (!$this->_acl->hasCreatePerms()) {
+		if (!Core_AclHelper::hasCreatePerms($acl)) {
 			?>
 <div class="container">
 	<div class="alert alert-danger">