Quellcode durchsuchen

Acl table proces init map; fix execute perms by main proces init id

Piotr Labudda vor 10 Jahren
Ursprung
Commit
9b45a25ddc
2 geänderte Dateien mit 93 neuen und 14 gelöschten Zeilen
  1. 51 13
      SE/se-lib/TableAjax.php
  2. 42 1
      SE/se-lib/UserAcl.php

+ 51 - 13
SE/se-lib/TableAjax.php

@@ -234,8 +234,14 @@ class TableAjax extends ViewAjax {
 	}
 
 	public function render() {
-		$pInitList = $this->_fetchConnectedProcesInitList();
-		$pInitListSelected = $this->getProcesInitSelected();
+		{
+			$pInitList = $this->_fetchConnectedProcesInitList();
+			$userAcl = User::getAcl();
+			$procesIds = array_keys($pInitList);
+			$mapTree = $userAcl->getProcesInitMapTreeOnlyIds($procesIds);
+			DBG::_('DBG_MAP', '1', "mapTree", $mapTree, __CLASS__, __FUNCTION__, __LINE__);
+			$pInitListSelected = $this->getProcesInitSelected();
+		}
 		$hasGeomFlds = $this->hasGeomFields();
 
 		$tblAjaxMap = null;
@@ -393,22 +399,23 @@ class TableAjax extends ViewAjax {
 							<span class="caret"></span>
 						</a>
 						<ul class="dropdown-menu pull-left">
-							<?php foreach ($pInitList as $kId => $vLabel) : ?>
-								<?php if ($pInitListSelected && $pInitListSelected == $kId) : ?>
+							<?php foreach ($mapTree as $vInitId => $gotoIds) : ?>
+								<?php if ($pInitListSelected && $pInitListSelected == $vInitId) : ?>
 								<li class="disabled">
 								<?php else : ?>
 								<li>
 								<?php endif; ?>
-									<a href="procesy5.php?task=PROCES_VIEW_LIST&id_proces=<?php echo $kId; ?>&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1" target="_blank" style="display:none"><i class="glyphicon glyphicon-info-sign"></i></a>
-									<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=<?php echo $kId; ?>&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $this->_zasobID; ?>" title="<?php echo htmlspecialchars("{{$kId}} {$vLabel}"); ?>">
-										<i class="glyphicon glyphicon-info-sign"
-											 onclick="window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=<?php echo $kId; ?>&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;"
-											 style="color:#aaa;"
-											 onmouseover="this.style.color='#337AB7'"
-											 onmouseout="this.style.color='#aaa'"></i>
-										<?php echo "{{$kId}} " . V::strShortUtf8($vLabel, 50); ?>
-									</a>
+									<?php $this->_viewProcesInitListItem($vInitId, $gotoIds, $pInitList); ?>
 								</li>
+								<?php foreach ($gotoIds as $vGotoId => $vBool) : ?>
+									<?php if ($pInitListSelected && $pInitListSelected == $vGotoId) : ?>
+									<li class="disabled">
+									<?php else : ?>
+									<li>
+									<?php endif; ?>
+										<?php $this->_viewProcesGotoAndRetListItem($vGotoId, $pInitList); ?>
+									</li>
+								<?php endforeach; ?>
 							<?php endforeach; ?>
 						</ul>
 					</div>
@@ -2940,6 +2947,37 @@ function hidePopover() {
 		return $out;
 	}
 
+	public function _viewProcesInitListItem($vInitId, $gotoIds, $pInitList) {
+		$vLabel = $pInitList[$vInitId];
+		$kId = $vInitId;
+		?>
+		<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=<?php echo $kId; ?>&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $this->_zasobID; ?>" title="<?php echo htmlspecialchars("{{$kId}} {$vLabel}"); ?>">
+			<i class="glyphicon glyphicon-info-sign"
+				 onclick="window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=<?php echo $kId; ?>&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;"
+				 style="color:#aaa;"
+				 onmouseover="this.style.color='#337AB7'"
+				 onmouseout="this.style.color='#aaa'"></i>
+			<?php echo "{{$kId}} " . V::strShortUtf8($vLabel, 50); ?>
+		</a>
+<?php
+	}
+	public function _viewProcesGotoAndRetListItem($vGotoId, $pInitList) {
+		$vLabel = $pInitList[$vGotoId];
+		$kId = $vGotoId;
+		// TODO:?: prevent to execute procedure
+		?>
+		<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=<?php echo $kId; ?>&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $this->_zasobID; ?>" title="<?php echo htmlspecialchars("{{$kId}} {$vLabel}"); ?>">
+			<i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>
+			<i class="glyphicon glyphicon-info-sign"
+				 onclick="window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=<?php echo $kId; ?>&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;"
+				 style="color:#aaa;"
+				 onmouseover="this.style.color='#337AB7'"
+				 onmouseout="this.style.color='#aaa'"></i>
+			<?php echo "{{$kId}} " . V::strShortUtf8($vLabel, 50); ?>
+		</a>
+<?php
+	}
+
 	public function hasAdditionalLayers() {
 		$layers = TableAjaxMap::getAdditionalLayers($this->_zasobID);
 		return !empty($layers);

+ 42 - 1
SE/se-lib/UserAcl.php

@@ -400,7 +400,7 @@ SQL;
 			return <<<SQL
 				select i.`ID_PROCES`
 					from `CRM_PROCES_idx` i
-					where i.`idx_PROCES_INIT_ID`='{$filterIdProces}'
+					where i.`idx_MAIN_PROCES_INIT_ID`='{$filterIdProces}'
 SQL;
 		}
 
@@ -616,4 +616,45 @@ SQL;
 		return $canExecuteProcesInit;
 	}
 
+	public function getProcesInitMapTreeOnlyIds($ids) {
+		$mapTree = array();
+		$map = $this->getProcesInitMapOnlyIds($ids);
+		foreach ($map as $r) {
+			if ('PROCES_INIT' == $r->TYPE) {
+				$mapTree[$r->ID_PROCES] = array();
+			}
+		}
+		foreach ($map as $r) {
+			if ('GOTO_AND_RETURN' == $r->TYPE) {
+				$mapTree[$r->idx_MAIN_PROCES_INIT_ID][$r->ID_PROCES] = true;
+			}
+		}
+		return $mapTree;
+	}
+
+	public function getProcesInitMapOnlyIds($ids) {
+		$map = array();
+		$sqlIds = V::filter($ids, array('V', 'filterPositiveInteger'));
+		$sqlIds = implode(',', $sqlIds);
+		if (empty($sqlIds)) return $map;
+		$sql = <<<SQL
+			select i.`ID_PROCES`
+				, i.`PARENT_ID`
+				, i.`TYPE`
+				, i.`idx_PROCES_INIT_ID`
+				, i.`idx_MAIN_PROCES_INIT_ID`
+				, i.`idx_PROCES_WITH_GROUPS_ID`
+			from `CRM_PROCES_idx` i
+			where i.`ID_PROCES` in({$sqlIds})
+				and i.`idx_MAIN_PROCES_INIT_ID` in({$sqlIds})
+SQL;
+		DBG::_('DBG_MAP', '1', "MAP SQL", $sql, __CLASS__, __FUNCTION__, __LINE__);
+		$db = DB::getDB();
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$map[] = $r;
+		}
+		return $map;
+	}
+
 }