From 7292a8540b7a0c18010cfac4d3f6978367bd724e Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 13 Sep 2023 10:53:32 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06547=20-=20Disallow=20linkset=20edition?= =?UTF-8?q?=20when=20lnk=20attribute=20is=20readonly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Links/AbstractBlockLinkSetViewTable.php | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/sources/Application/UI/Links/AbstractBlockLinkSetViewTable.php b/sources/Application/UI/Links/AbstractBlockLinkSetViewTable.php index ee2d91546..dfc1522e3 100644 --- a/sources/Application/UI/Links/AbstractBlockLinkSetViewTable.php +++ b/sources/Application/UI/Links/AbstractBlockLinkSetViewTable.php @@ -70,6 +70,9 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock /** @var AttributeLinkedSet $oAttDef attribute link set */ protected AttributeLinkedSet $oAttDef; + /** @var bool $bIsAttEditable Is attribute editable */ + protected bool $bIsAttEditable; + /** @var string $sTargetClass links target classname */ protected string $sTargetClass; @@ -119,11 +122,12 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock private function Init() { $this->sTargetClass = $this->GetTargetClass(); - + $this->InitIsAttEditable(); + // User rights - $this->bIsAllowCreate = UserRights::IsActionAllowed($this->oAttDef->GetLinkedClass(), UR_ACTION_CREATE) == UR_ALLOWED_YES; - $this->bIsAllowModify = UserRights::IsActionAllowed($this->oAttDef->GetLinkedClass(), UR_ACTION_MODIFY) == UR_ALLOWED_YES; - $this->bIsAllowDelete = UserRights::IsActionAllowed($this->oAttDef->GetLinkedClass(), UR_ACTION_DELETE) == UR_ALLOWED_YES; + $this->bIsAllowCreate = $this->bIsAttEditable && UserRights::IsActionAllowed($this->oAttDef->GetLinkedClass(), UR_ACTION_CREATE) == UR_ALLOWED_YES; + $this->bIsAllowModify = $this->bIsAttEditable && UserRights::IsActionAllowed($this->oAttDef->GetLinkedClass(), UR_ACTION_MODIFY) == UR_ALLOWED_YES; + $this->bIsAllowDelete = $this->bIsAttEditable && UserRights::IsActionAllowed($this->oAttDef->GetLinkedClass(), UR_ACTION_DELETE) == UR_ALLOWED_YES; } @@ -196,6 +200,26 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock $this->AddSubBlock($oBlock->GetRenderContent($oPage, $this->GetExtraParam(), $this->sTableId)); } + /** + * @return void + * @throws \CoreException + */ + private function InitIsAttEditable(): void + { + $iFlags = 0; + + if ($this->oDbObject->IsNew()) + { + $iFlags = $this->oDbObject->GetInitialStateAttributeFlags($this->sAttCode); + } + else + { + $iFlags = $this->oDbObject->GetAttributeFlags($this->sAttCode); + } + + $this->bIsAttEditable = !($iFlags & (OPT_ATT_READONLY | OPT_ATT_SLAVE | OPT_ATT_HIDDEN)); + } + /** * GetTableId. *