diff --git a/Dao/TagsDao.php b/Dao/TagsDao.php index 9c0167f5e..854f3d40b 100644 --- a/Dao/TagsDao.php +++ b/Dao/TagsDao.php @@ -57,9 +57,9 @@ private function isNameInUse($idSite, $idContainerVersion, $name, $exceptIdTag = return !empty($idSite); } - public function createTag($idSite, $idContainerVersion, $type, $name, $parameters, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate, $createdDate) + public function createTag($idSite, $idContainerVersion, $type, $name, $parameters, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate, $createdDate, $checkNameInUse = true) { - if ($this->isNameInUse($idSite, $idContainerVersion, $name)) { + if ($checkNameInUse && $this->isNameInUse($idSite, $idContainerVersion, $name)) { throw new Exception(Piwik::translate('TagManager_ErrorNameDuplicate')); } diff --git a/Dao/TriggersDao.php b/Dao/TriggersDao.php index ab49053ba..d7c5700a0 100644 --- a/Dao/TriggersDao.php +++ b/Dao/TriggersDao.php @@ -50,9 +50,9 @@ private function isNameInUse($idSite, $idContainerVersion, $name, $exceptIdTrigg return !empty($idSite); } - public function createTrigger($idSite, $idContainerVersion, $type, $name, $parameters, $conditions, $createdDate) + public function createTrigger($idSite, $idContainerVersion, $type, $name, $parameters, $conditions, $createdDate, $checkNameInUse = true) { - if ($this->isNameInUse($idSite, $idContainerVersion, $name)) { + if ($checkNameInUse && $this->isNameInUse($idSite, $idContainerVersion, $name)) { throw new Exception(Piwik::translate('TagManager_ErrorNameDuplicate')); } diff --git a/Dao/VariablesDao.php b/Dao/VariablesDao.php index 23ca8ed33..6a46bf27f 100644 --- a/Dao/VariablesDao.php +++ b/Dao/VariablesDao.php @@ -51,9 +51,9 @@ private function isNameInUse($idSite, $idContainerVersion, $name, $exceptIdVaria return !empty($idSite); } - public function createVariable($idSite, $idContainerVersion, $type, $name, $parameters, $defaultValue, $lookupTable, $createdDate) + public function createVariable($idSite, $idContainerVersion, $type, $name, $parameters, $defaultValue, $lookupTable, $createdDate, $checkNameInUse = true) { - if ($this->isNameInUse($idSite, $idContainerVersion, $name)) { + if ($checkNameInUse && $this->isNameInUse($idSite, $idContainerVersion, $name)) { throw new Exception(Piwik::translate('TagManager_ErrorNameDuplicate')); } diff --git a/Model/Tag.php b/Model/Tag.php index c848acc16..0b451ea25 100644 --- a/Model/Tag.php +++ b/Model/Tag.php @@ -53,7 +53,7 @@ public function getFireLimits() ]; } - public function addContainerTag($idSite, $idContainerVersion, $type, $name, $parameters, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate) + public function addContainerTag($idSite, $idContainerVersion, $type, $name, $parameters, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate, $checkNameInUse = true) { $this->validateValues($idSite, $name, $idContainerVersion, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate); $this->tagsProvider->checkIsValidTag($type); @@ -61,7 +61,7 @@ public function addContainerTag($idSite, $idContainerVersion, $type, $name, $par $createdDate = $this->getCurrentDateTime(); - return $this->dao->createTag($idSite, $idContainerVersion, $type, $name, $parameters, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate, $createdDate); + return $this->dao->createTag($idSite, $idContainerVersion, $type, $name, $parameters, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate, $createdDate, $checkNameInUse); } private function validateValues($idSite, $name, $idContainerVersion, $fireTriggerIds, $blockTriggerIds, $fireLimit, $fireDelay, $priority, $startDate, $endDate) diff --git a/Model/Trigger.php b/Model/Trigger.php index 4e4d3553c..ca221486a 100644 --- a/Model/Trigger.php +++ b/Model/Trigger.php @@ -51,14 +51,14 @@ private function validateValues($idSite, $name, $idContainerVersion, $conditions BaseValidator::check('Conditions', $conditions, [new TriggerConditions($idSite, $idContainerVersion)]); } - public function addContainerTrigger($idSite, $idContainerVersion, $type, $name, $parameters, $conditions) + public function addContainerTrigger($idSite, $idContainerVersion, $type, $name, $parameters, $conditions, $checkNameInUse = true) { $this->validateValues($idSite, $name, $idContainerVersion, $conditions); $this->triggersProvider->checkIsValidTrigger($type); $parameters = $this->formatParameters($type, $parameters); $createdDate = $this->getCurrentDateTime(); - return $this->dao->createTrigger($idSite, $idContainerVersion, $type, $name, $parameters, $conditions, $createdDate); + return $this->dao->createTrigger($idSite, $idContainerVersion, $type, $name, $parameters, $conditions, $createdDate, $checkNameInUse); } public function updateContainerTrigger($idSite, $idContainerVersion, $idTrigger, $name, $parameters, $conditions) diff --git a/Model/Variable.php b/Model/Variable.php index afff08c2a..78fb5c5c7 100644 --- a/Model/Variable.php +++ b/Model/Variable.php @@ -71,13 +71,13 @@ private function validateValues($idSite, $name, $defaultValue, $lookupTable) BaseValidator::check(Piwik::translate('TagManager_LookupTable'), $lookupTable, [new LookupTable()]); } - public function addContainerVariable($idSite, $idContainerVersion, $type, $name, $parameters, $defaultValue, $lookupTable) + public function addContainerVariable($idSite, $idContainerVersion, $type, $name, $parameters, $defaultValue, $lookupTable, $checkNameInUse = true) { $this->validateValues($idSite, $name, $defaultValue, $lookupTable); $this->variablesProvider->checkIsValidVariable($type); $createdDate = $this->getCurrentDateTime(); $parameters = $this->formatParameters($type, $parameters); - return $this->dao->createVariable($idSite, $idContainerVersion, $type, $name, $parameters, $defaultValue, $lookupTable, $createdDate); + return $this->dao->createVariable($idSite, $idContainerVersion, $type, $name, $parameters, $defaultValue, $lookupTable, $createdDate, $checkNameInUse); } public function updateContainerVariable($idSite, $idContainerVersion, $idVariable, $name, $parameters, $defaultValue, $lookupTable)