SAAS-1081 - implement station podcast download counter that resets monthly

This commit is contained in:
Duncan Sommerville 2015-10-21 12:54:50 -04:00
parent 6c0055895c
commit 92ffa955c3
7 changed files with 94 additions and 23 deletions

View file

@ -1526,6 +1526,9 @@ class Application_Model_Preference
self::setValue("station_podcast_id", $value);
}
// SAAS-1081 - Implement a universal download key for downloading episodes from the station podcast
// Store and increment the download counter, resetting every month
public static function getStationPodcastDownloadKey() {
return self::getValue("station_podcast_download_key");
}
@ -1534,4 +1537,31 @@ class Application_Model_Preference
$value = empty($value) ? (new Application_Model_Auth())->generateRandomString() : $value;
self::setValue("station_podcast_download_key", $value);
}
public static function getStationPodcastDownloadResetTimer() {
return self::getValue("station_podcast_download_reset_timer");
}
public static function setStationPodcastDownloadResetTimer($value) {
self::setValue("station_podcast_download_reset_timer", $value);
}
public static function getStationPodcastDownloadCounter() {
return self::getValue("station_podcast_download_counter");
}
public static function resetStationPodcastDownloadCounter() {
self::setValue("station_podcast_download_counter", 0);
}
public static function incrementStationPodcastDownloadCounter() {
$c = self::getStationPodcastDownloadCounter();
self::setValue("station_podcast_download_counter", empty($c) ? 1 : ++$c);
}
// For fail cases, we may need to decrement the download counter
public static function decrementStationPodcastDownloadCounter() {
$c = self::getStationPodcastDownloadCounter();
self::setValue("station_podcast_download_counter", empty($c) ? 0 : --$c);
}
}