Browse Source

FIX BUG default acl group on create new record

Piotr Labudda 11 năm trước cách đây
mục cha
commit
8c25b78e5a
2 tập tin đã thay đổi với 22 bổ sung1 xóa
  1. 5 0
      SE/se-lib/Data_Source.php
  2. 17 1
      SE/se-lib/TableAjax.php

+ 5 - 0
SE/se-lib/Data_Source.php

@@ -691,6 +691,11 @@ if(V::get('DBG_DS', 0, $_GET) > 2){echo'<pre style="max-height:200px;overflow:au
 		return $affected;
 	}
 
+	public function addItem($item) {
+		$id = $this->_db->ADD_NEW_OBJ($this->_tbl, $item);
+		return $id;
+	}
+
 	public function getDbErrors() {
 		$errors = array();
 		if ($this->_db->has_errors()) {

+ 17 - 1
SE/se-lib/TableAjax.php

@@ -3398,7 +3398,23 @@ jQuery(document).ready(function(){
 		}
 		if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sqlObj);echo'</pre>';}
 
-		$retID = $db->ADD_NEW_OBJ($tblName, $sqlObj);
+		{// add DefaultAclGroup if no create perms ('C')
+			$defaultAclGroup = User::getDefaultAclGroup();
+			if ($defaultAclGroup) {
+				foreach ($fields as $kID => $vField) {
+					if (!$this->_acl->isAllowed($kID, 'C')) {
+						if ($vField['name'] == 'A_ADM_COMPANY') {
+							$sqlObj->{$vField['name']} = $defaultAclGroup;
+						}
+						else if ($vField['name'] == 'A_CLASSIFIED') {
+							$sqlObj->{$vField['name']} = $defaultAclGroup;
+						}
+					}
+				}
+			}
+		}
+
+		$retID = $this->_dataSource->addItem($sqlObj);
 
 		$retJson = new stdClass();
 		$retJson->type = '';