This commit is contained in:
2017-07-31 01:16:46 +02:00
parent decdc7abd7
commit 3f7af298f2
4 changed files with 41 additions and 15 deletions

View File

@@ -12,6 +12,7 @@ class Podcast extends Model {
public $created;
public $program;
public $url;
public $auth;
public $download;
private $key;
@@ -19,11 +20,19 @@ class Podcast extends Model {
parent::__construct($data);
parent::ConvertToDateTime($this->created);
$this->key = sha1($this->id . ':' . session_id() . ':' . $this->soundfilename);
$this->url = $this->id . '/' . parent::url_slug($this->title) . '?auth=' . $this->key;
if($this->program != 0) {
$this->program = new \Model\Program(['id' => $this->program, 'name' => $data->program_name, 'description' => $data->program_description]);
$this->url = $this->id . '/' . parent::url_slug($this->title);
if($this->soundfilename) {
// Only generate when not constructing from a JSON object
$this->key = sha1($this->id . ':' . date('Y-m-d') . ':' . $this->soundfilename);
$this->auth = $this->key;
}
if($data->program) {
if(is_object($data->program)) {
$this->program = new \Model\Program($data->program);
} else {
$this->program = new \Model\Program(['id' => $this->program, 'name' => $data->program_name, 'description' => $data->program_description]);
}
}
}
@@ -32,7 +41,7 @@ class Podcast extends Model {
}
public function getSoundfile() {
return '/tmp/podcast.mp3';
return '/var/audio/podcast/' . $this->soundfilename;
}
public function excerpt() {

View File

@@ -25,7 +25,7 @@ class Program extends Model {
}
}
if(($mailComma = strpos($data->email, ',')) !== false) {
if(isset($data->email) && ($mailComma = strpos($data->email, ',')) !== false) {
$this->email = substr($data->email, 0, $mailComma);
}