Merge branch 'cc-5709-airtime-analyzer' into cc-5709-airtime-analyzer-saas

This commit is contained in:
drigato 2014-05-12 11:30:26 -04:00
commit d312c844bc
1 changed files with 17 additions and 0 deletions

View File

@ -214,6 +214,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$requestData = json_decode($this->getRequest()->getRawBody(), true);
$whiteList = $this->removeBlacklistedFieldsFromRequestData($requestData);
$whiteList = $this->stripTimeStampFromYearTag($whiteList);
if (!$this->validateRequestData($file, $whiteList)) {
$file->save();
@ -479,5 +480,21 @@ class Rest_MediaController extends Zend_Rest_Controller
exec("find $path -empty -type d -delete");
}
/*
* It's possible that the year tag will be a timestamp but Airtime doesn't support this.
* The year field in cc_files can only be 16 chars max.
*
* This functions strips the year field of it's timestamp, if one, and leaves just the year
*/
private function stripTimeStampFromYearTag($metadata)
{
if (isset($metadata["year"])) {
if (preg_match("/^(\d{4})-(\d{2})-(\d{2})(?:\s+(\d{2}):(\d{2}):(\d{2}))?$/", $metadata["year"])) {
$metadata["year"] = substr($metadata["year"], 0, 4);
}
}
return $metadata;
}
}