piwik/plugins/SitesManager/API.php
/**
     * Update an existing website.
     * If only one URL is specified then only the main url will be updated.
     * If several URLs are specified, both the main URL and the alias URLs will be updated.
     *
     * @param int $idSite website ID defining the website to edit
     * @param string $siteName website name
     * @param string|array $urls the website URLs
     * @param int $ecommerce Whether Ecommerce is enabled, 0 or 1
     * @param null|int $siteSearch Whether site search is enabled, 0 or 1
     * @param string $searchKeywordParameters Comma separated list of search keyword parameter names
     * @param string $searchCategoryParameters Comma separated list of search category parameter names
     * @param string $excludedIps Comma separated list of IPs to exclude from being tracked (allows wildcards)
     * @param null|string $excludedQueryParameters
     * @param string $timezone Timezone
     * @param string $currency Currency code
     * @param string $group Group name where this website belongs
     * @param string $startDate Date at which the statistics for this website will start. Defaults to today's date in YYYY-MM-DD format
     * @param null|string $excludedUserAgents
     * @param int|null $keepURLFragments If 1, URL fragments will be kept when tracking. If 2, they
     *                                   will be removed. If 0, the default global behavior will be used.
     * @param string $type The Website type, default value is "website"
     * @throws Exception
     * @see getKeepURLFragmentsGlobal. If null, the existing value will
     *                                   not be modified.
     *
     * @return bool true on success
     */
Update an existing website.
If only one URL is specified then only the main url will be updated.
If several URLs are specified, both the main URL and the alias URLs will be updated.



@return bool true on success
Update an existing website . If only one URL is specified then only the main url will be updated . If several URLs are specified both the main URL and the alias URLs will be updated . @return bool true on success
public function updateSite($idSite,
                               $siteName = null,
                               $urls = null,
                               $ecommerce = null,
                               $siteSearch = null,
                               $searchKeywordParameters = null,
                               $searchCategoryParameters = null,
                               $excludedIps = null,
                               $excludedQueryParameters = null,
                               $timezone = null,
                               $currency = null,
                               $group = null,
                               $startDate = null,
                               $excludedUserAgents = null,
                               $keepURLFragments = null,
                               $type = null)
    {
        Piwik::checkUserHasAdminAccess($idSite);
        $idSites = API::getInstance()->getSitesId();
        if (!in_array($idSite, $idSites)) {
            throw new Exception("website id = $idSite not found");
        }
        $bind = array();
        if (!is_null($siteName)) {
            $this->checkName($siteName);
            $bind['name'] = $siteName;
        }
        if (!is_null($urls)) {
            $urls = $this->cleanParameterUrls($urls);
            $this->checkUrls($urls);
            $this->checkAtLeastOneUrl($urls);
            $url = $urls[0];
            $bind['main_url'] = $url;
        }
        if (!is_null($currency)) {
            $currency = trim($currency);
            $this->checkValidCurrency($currency);
            $bind['currency'] = $currency;
        }
        if (!is_null($timezone)) {
            $timezone = trim($timezone);
            $this->checkValidTimezone($timezone);
            $bind['timezone'] = $timezone;
        }
        if (!is_null($group)
            && Piwik::hasUserSuperUserAccess()
        ) {
            $bind['group'] = trim($group);
        }
        if (!is_null($ecommerce)) {
            $bind['ecommerce'] = (int)(bool)$ecommerce;
        }
        if (!is_null($startDate)) {
            $bind['ts_created'] = Date::factory($startDate)->getDatetime();
        }
        $bind['excluded_ips'] = $this->checkAndReturnExcludedIps($excludedIps);
        $bind['excluded_parameters'] = $this->checkAndReturnCommaSeparatedStringList($excludedQueryParameters);
        $bind['excluded_user_agents'] = $this->checkAndReturnCommaSeparatedStringList($excludedUserAgents);
        if (!is_null($keepURLFragments)) {
            $keepURLFragments = (int)$keepURLFragments;
            self::checkKeepURLFragmentsValue($keepURLFragments);
            $bind['keep_url_fragment'] = $keepURLFragments;
        }
        $bind['sitesearch'] = $this->checkSiteSearch($siteSearch);
        list($searchKeywordParameters, $searchCategoryParameters) = $this->checkSiteSearchParameters($searchKeywordParameters, $searchCategoryParameters);
        $bind['sitesearch_keyword_parameters'] = $searchKeywordParameters;
        $bind['sitesearch_category_parameters'] = $searchCategoryParameters;
        $bind['type'] = $this->checkAndReturnType($type);
        $this->getModel()->updateSite($bind, $idSite);
        $this->getModel()->deleteSiteAliasUrls($idSite);
        if (count($urls) > 1) {
            $this->addSiteAliasUrls($idSite, array_slice($urls, 1));
        }
        $this->postUpdateWebsite($idSite);
    }
public function updateSite ( $ idSite , $ siteName = null , $ urls = null , $ ecommerce = null , $ siteSearch = null , $ searchKeywordParameters = null , $ searchCategoryParameters = null , $ excludedIps = null , $ excludedQueryParameters = null , $ timezone = null , $ currency = null , $ group = null , $ startDate = null , $ excludedUserAgents = null , $ keepURLFragments = null , $ type = null ) { Piwik :: checkUserHasAdminAccess ( $ idSite ) ; $ idSites = API :: getInstance ( ) -> getSitesId ( ) ; if ( ! in_array ( $ idSite , $ idSites ) ) { throw new Exception ( " website id =  $ idSite  not found " ) ; } $ bind = array ( ) ; if ( ! is_null ( $ siteName ) ) { $ this -> checkName ( $ siteName ) ; $ bind [ 'name' ] = $ siteName ; } if ( ! is_null ( $ urls ) ) { $ urls = $ this -> cleanParameterUrls ( $ urls ) ; $ this -> checkUrls ( $ urls ) ; $ this -> checkAtLeastOneUrl ( $ urls ) ; $ url = $ urls [ 0 ] ; $ bind [ 'main_url' ] = $ url ; } if ( ! is_null ( $ currency ) ) { $ currency = trim ( $ currency ) ; $ this -> checkValidCurrency ( $ currency ) ; $ bind [ 'currency' ] = $ currency ; } if ( ! is_null ( $ timezone ) ) { $ timezone = trim ( $ timezone ) ; $ this -> checkValidTimezone ( $ timezone ) ; $ bind [ 'timezone' ] = $ timezone ; } if ( ! is_null ( $ group ) && Piwik :: hasUserSuperUserAccess ( ) ) { $ bind [ 'group' ] = trim ( $ group ) ; } if ( ! is_null ( $ ecommerce ) ) { $ bind [ 'ecommerce' ] = ( int ) ( bool ) $ ecommerce ; } if ( ! is_null ( $ startDate ) ) { $ bind [ 'ts_created' ] = Date :: factory ( $ startDate ) -> getDatetime ( ) ; } $ bind [ 'excluded_ips' ] = $ this -> checkAndReturnExcludedIps ( $ excludedIps ) ; $ bind [ 'excluded_parameters' ] = $ this -> checkAndReturnCommaSeparatedStringList ( $ excludedQueryParameters ) ; $ bind [ 'excluded_user_agents' ] = $ this -> checkAndReturnCommaSeparatedStringList ( $ excludedUserAgents ) ; if ( ! is_null ( $ keepURLFragments ) ) { $ keepURLFragments = ( int ) $ keepURLFragments ; self :: checkKeepURLFragmentsValue ( $ keepURLFragments ) ; $ bind [ 'keep_url_fragment' ] = $ keepURLFragments ; } $ bind [ 'sitesearch' ] = $ this -> checkSiteSearch ( $ siteSearch ) ; list ( $ searchKeywordParameters , $ searchCategoryParameters ) = $ this -> checkSiteSearchParameters ( $ searchKeywordParameters , $ searchCategoryParameters ) ; $ bind [ 'sitesearch_keyword_parameters' ] = $ searchKeywordParameters ; $ bind [ 'sitesearch_category_parameters' ] = $ searchCategoryParameters ; $ bind [ 'type' ] = $ this -> checkAndReturnType ( $ type ) ; $ this -> getModel ( ) -> updateSite ( $ bind , $ idSite ) ; $ this -> getModel ( ) -> deleteSiteAliasUrls ( $ idSite ) ; if ( count ( $ urls ) > 1 ) { $ this -> addSiteAliasUrls ( $ idSite , array_slice ( $ urls , 1 ) ) ; } $ this -> postUpdateWebsite ( $ idSite ) ; }
Update an existing website.
Update an existing website .
// Build the SQL UPDATE based on specified updates to perform // we now update the main + alias URLs