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

added filtr procesu to wfs data api

Piotr Labudda 9 лет назад
Родитель
Сommit
531279db5e
2 измененных файлов с 18 добавлено и 3 удалено
  1. 18 2
      SE/se-lib/Api/WfsData.php
  2. 0 1
      SE/se-lib/Api/WfsQgis.php

+ 18 - 2
SE/se-lib/Api/WfsData.php

@@ -11,6 +11,7 @@ class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 
 	public $_apiUser;
 	public $_apiBaseUri;
+	public $_idFiltrProces;
 	public $_dataSourceName;
 	public $_tblName;
 	public $_tblSchema;
@@ -25,7 +26,15 @@ class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 			//$this->mainWpsAction($request);// show list of posible data source
 			throw new HttpException("Bad Request", 400);
 		} else {
-			$this->_dataSourceName = array_shift($request->segments);
+			$pathPart = array_shift($request->segments);
+			if ('filtr_proces_' == substr($pathPart, 0, 13)) {
+				$this->_idFiltrProces = (int)substr($pathPart, 13);
+				if (!$this->_idFiltrProces) throw new Api_WfsException("Wrong filtr process number");
+				$this->DBG("filtr procesu({$idProcesFiltr})", __LINE__, __FUNCTION__, __CLASS__);
+
+				$pathPart = array_shift($request->segments);
+			}
+			$this->_dataSourceName = $pathPart;
 			$this->DBG("dataSourceAction({$this->_dataSourceName}) ...", __LINE__);
 			try {
 				$this->dataSourceAction($request);
@@ -51,7 +60,14 @@ class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 		IF(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">user (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_apiUser);echo'</pre>';}
 		$userAcl = new UserAcl($this->_apiUser->getID(), $use_cache = true);
 		$userAcl->fetchGroups();
-		$userAcl->fetchAllPerms(true);
+		if ($this->_idFiltrProces) {
+			if (!$userAcl->canExecuteProcesInit($this->_idFiltrProces)) {
+				throw new Api_WfsException("Access Denied for given process");
+			}
+			$userAcl->fetchProcesPerms($this->_idFiltrProces, true);
+		} else {
+			$userAcl->fetchAllPerms(true);
+		}
 		IF(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$userAcl (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($userAcl);echo'</pre>';}
 
 		$this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);

+ 0 - 1
SE/se-lib/Api/WfsQgis.php

@@ -68,7 +68,6 @@ class Api_WfsQgis extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 		} else {
 			$userAcl->fetchAllPerms(true);
 		}
-
 		DBG::_('DBG', '>2', 'userAcl', $userAcl, __CLASS__, __FUNCTION__, __LINE__);
 
 		$this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);