/** * Sets the options used by this class based on the elements in $options. * * The following elements of $options are used: * 'loc' - URL for location database. * 'isp' - URL for ISP database. * 'org' - URL for Organization database. * 'period' - 'weekly' or 'monthly'. When to run the updates. * * @param array $options * @throws Exception */ public static function setUpdaterOptions($options) { // set url options foreach (self::$urlOptions as $optionKey => $optionName) { if (!isset($options[$optionKey])) { continue; } $url = $options[$optionKey]; $url = self::removeDateFromUrl($url); Option::set($optionName, $url); } // set period option if (!empty($options['period'])) { $period = $options['period']; if ($period != self::SCHEDULE_PERIOD_MONTHLY && $period != self::SCHEDULE_PERIOD_WEEKLY) { throw new Exception(Piwik::translate('UserCountry_InvalidGeoIPUpdatePeriod', array("'{$period}'", "'" . self::SCHEDULE_PERIOD_MONTHLY . "', '" . self::SCHEDULE_PERIOD_WEEKLY . "'"))); } Option::set(self::SCHEDULE_PERIOD_OPTION_NAME, $period); TaskScheduler::rescheduleTask(new GeoIPAutoUpdater()); } }