feat(legacy): add current date macro to string block criteria (#3013)

### Description

It is useful to be able to automatically filter tracks to a certain date
or day when scheduling tracks for playback. This adds the ability to do
just that in any string filter with the `date{format}` macro.

 
 Closes:  #3012
This commit is contained in:
dakriy 2024-06-22 02:19:21 -07:00 committed by GitHub
parent 13a8e38beb
commit 451652bc40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -1612,6 +1612,19 @@ SQL;
return $storedCrit;
}
private function resolveDate($value)
{
if (!is_string($value)) {
return $value;
}
return preg_replace_callback(
'/now{(.*?)}/',
fn ($matches) => date($matches[1]),
$value
);
}
// this function return list of propel object
public function getListofFilesMeetCriteria($showLimit = null)
{
@ -1677,6 +1690,8 @@ SQL;
$spCriteriaExtra = $criteria['extra'];
}
$spCriteriaValue = $this->resolveDate($spCriteriaValue);
if ($spCriteriaModifier == 'starts with') {
$spCriteriaValue = "{$spCriteriaValue}%";
} elseif ($spCriteriaModifier == 'ends with') {