Explorar o código

TableAjax add link to Create in breadcrumbs when it is allowed

Piotr Labudda %!s(int64=10) %!d(string=hai) anos
pai
achega
3dc1c0fa97
Modificáronse 2 ficheiros con 26 adicións e 0 borrados
  1. 7 0
      SE/se-lib/TableAcl.php
  2. 19 0
      SE/se-lib/TableAjax.php

+ 7 - 0
SE/se-lib/TableAcl.php

@@ -201,6 +201,13 @@ class TableAcl {
 		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')) {

+ 19 - 0
SE/se-lib/TableAjax.php

@@ -239,6 +239,8 @@ class TableAjax extends ViewAjax {
 			$tblAjaxMap = new TableAjaxMap($this->_acl, 512, 400);
 		}
 
+		$hasPermCreate = $this->_acl->hasCreatePerms();
+
 		$jsToogleFiltrProcesuFunctionName = 'tableAjaxToggleFiltrProcesInit';
 		ob_start();
 		?>
@@ -384,6 +386,12 @@ class TableAjax extends ViewAjax {
 		<div class="AjaxTableCont">
 			<ul class="breadcrumb">
 				<li><a href="#" onclick="return tableAjaxBackToTable();"><?php echo $this->getLabelHtml(); ?></a></li>
+				<!-- TODO: if has perm 'C' then add btn to create new record -->
+				<?php if ($hasPermCreate) : ?>
+					<li><a title="Dodaj nowy rekord"
+								 class=""
+								 href="#CREATE"><span class="glyphicon glyphicon-plus"></span> Dodaj nowy rekord</a></li>
+				<?php endif; ?>
 				<?php if ($this->_showProcesInit) : ?>
 				<div class="btn-group pull-right">
 					<a class="btn btn-xs btn-info dropdown-toggle"
@@ -3831,6 +3839,17 @@ jQuery(document).ready(function(){
 		header("Content-type: text/plain");
 		$DBG = ('1' == V::get('DBG', '', $_REQUEST));
 
+		if (!$this->_acl->hasCreatePerms()) {
+			?>
+<div class="container">
+	<div class="alert alert-danger">
+		Brak uprawnień do utworzenia nowego rekordu.
+	</div>
+</div>
+<?php
+			return;
+		}
+
 		$cols = array();
 		$forceFilterInit = array();