Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional check template name in use #521

Open
wants to merge 1 commit into
base: 4.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dao/TagsDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down
4 changes: 2 additions & 2 deletions Dao/TriggersDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down
4 changes: 2 additions & 2 deletions Dao/VariablesDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down
4 changes: 2 additions & 2 deletions Model/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ 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);
$parameters = $this->formatParameters($type, $parameters);

$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)
Expand Down
4 changes: 2 additions & 2 deletions Model/Trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Model/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down