/** * Invokes hook_mostpopular_service('throttles') on the given service to get * the default throttles to use for the currently-configured intervals. * * @param integer $sid * The service ID. * @return array * An array, hashed by $sid and by $iid, of the default throttle * strtotime() strings. */ public static function getDefaultThrottles($sid) { if (!isset(self::$default_throttles[$sid])) { $service = MostPopularService::fetch($sid); $intervals = MostPopularInterval::fetchAll(); $options = array(); foreach ($intervals as $interval) { $options[$interval->iid] = $interval->timestamp(); } $out = module_invoke($service->module, 'mostpopular_service', 'throttles', $service->delta, $options); foreach ($intervals as $interval) { if (!isset($out[$interval->iid])) { $out[$interval->iid] = ''; } } self::$default_throttles[$sid] = $out; } return self::$default_throttles; }
/** * Resets the list of intervals to the default settings. */ public static function reset() { self::clear(); $day = new MostPopularInterval(array('title' => t('Day'), 'string' => '-1 day', 'weight' => 0)); $day->save(); $week = new MostPopularInterval(array('title' => t('Week'), 'string' => '-1 week', 'weight' => 1)); $week->save(); $month = new MostPopularInterval(array('title' => t('Month'), 'string' => '-1 month', 'weight' => 2)); $month->save(); $year = new MostPopularInterval(array('title' => t('Year'), 'string' => '-1 year', 'weight' => 3)); $year->save(); }