From df466faddf5119982a8b3afab031c28f4bca14ba Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Wed, 1 Jun 2016 12:46:22 +0000 Subject: [PATCH] Demo mode: to not allow deleting neither changing the org of persons attached to a user account (this to make sure that the portal users will still have access to the customer portal) SVN:trunk[4164] --- .../datamodel.itop-config-mgmt.xml | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml index 04c8b00e65..ba8541e2e8 100755 --- a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml +++ b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml @@ -526,7 +526,84 @@ 0 - + + + false + public + Overload-DBObject + Get('demo_mode')) + { + if ($this->HasUserAccount()) + { + // Do not let users change user accounts in demo mode + $oDeletionPlan->AddToDelete($this, null); + $oDeletionPlan->SetDeletionIssues($this, array('deletion not allowed in demo mode.'), true); + $oDeletionPlan->ComputeResults(); + return false; + } + } + return parent::CheckToDelete($oDeletionPlan); + } +]]> + + + false + public + Overload-DBObject + Get('demo_mode')) + { + if ($this->HasUserAccount()) + { + // Do not let users change user accounts in demo mode + return; + } + } + parent::DBDeleteSingleObject(); + } +]]> + + + false + public + Overload-DBObject + IsNew()) ) + { + if (MetaModel::GetConfig()->Get('demo_mode')) + { + if ($this->HasUserAccount()) + { + // Do not let users change user accounts in demo mode + return OPT_ATT_READONLY; + } + } + } + return parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState); + } +]]> + + + false + public + Helper + $this->GetKey()))); + $bHasUserAccount = ($oUserSet->Count() > 0); + } + return $bHasUserAccount; + } +]]> + +