From 4b498be47204a663bef6c1a46bc42e65cf091784 Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Thu, 6 Feb 2014 10:40:28 +0000 Subject: [PATCH] Added a setSiteAliasUrls method to the API This method works in a similar way to the addSiteAliasUrls method, but it completely overwrites the URL list rather than merely adding to it. --- plugins/SitesManager/API.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index e36a9809a46..3e17f85f62f 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -712,6 +712,28 @@ public function addSiteAliasUrls($idSite, $urls) return count($toInsert); } + /** + * Set the list of alias Urls for the given idSite + * + * Completely overwrites the current list of URLs with the provided list. + * The 'main_url' of the website won't be affected by this method. + * + * @return int the number of inserted URLs + */ + public function setSiteAliasUrls($idSite, $urls) + { + Piwik::checkUserHasAdminAccess($idSite); + + $urls = $this->cleanParameterUrls($urls); + $this->checkUrls($urls); + + $this->deleteSiteAliasUrls($idSite); + $this->insertSiteUrls($idSite, $urls); + $this->postUpdateWebsite($idSite); + + return count($urls); + } + /** * Get the start and end IP addresses for an IP address range *