Load event using find_one which does caching.
parent
2cb697f0e9
commit
c811f1bc90
|
@ -116,30 +116,27 @@ class Event extends AppModel {
|
||||||
);
|
);
|
||||||
|
|
||||||
public function Relative_Path() {
|
public function Relative_Path() {
|
||||||
$Event = new ZM\Event($this->id);
|
$Event = ZM\Event::find_one(['Id'=>$this->id]);
|
||||||
return $Event->Relative_Path();
|
return $Event ? $Event->Relative_Path() : '';
|
||||||
} // end function Relative_Path()
|
} // end function Relative_Path()
|
||||||
|
|
||||||
public function Path() {
|
public function Path() {
|
||||||
$Event = new ZM\Event($this->id);
|
$Event = ZM\Event::find_one(['Id'=>$this->id]);
|
||||||
return $Event->Path();
|
return $Event ? $Event->Path() : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Link_Path() {
|
public function Link_Path() {
|
||||||
$Event = new ZM\Event($this->id);
|
$Event = ZM\Event::find_one(['Id'=>$this->id]);
|
||||||
return $Event->Link_Path();
|
return $Event ? $Event->Link_Path() : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fileExists($event) {
|
public function fileExists($event) {
|
||||||
//$data = $this->findById($id);
|
if ($event['DefaultVideo']) {
|
||||||
//return $data['Event']['dataset_filename'];
|
if (file_exists($this->Path().'/'.$event['DefaultVideo'])) {
|
||||||
$storage = $this->Storage->findById($event['StorageId']);
|
|
||||||
|
|
||||||
if ( $event['DefaultVideo'] ) {
|
|
||||||
if ( file_exists($this->Path().'/'.$event['DefaultVideo']) ) {
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
ZM\Warning('File does not exist at ' . $this->Path().'/'.$event['DefaultVideo'] );
|
ZM\Warning('File does not exist at ' . $this->Path().'/'.$event['DefaultVideo'] );
|
||||||
|
ZM\Warning(print_r($this, true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -151,8 +148,8 @@ class Event extends AppModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeDelete($cascade=true) {
|
public function beforeDelete($cascade=true) {
|
||||||
$Event = new ZM\Event($this->id);
|
$Event = ZM\Event::find_one(['Id'=>$this->id]);
|
||||||
$Event->delete();
|
if ($Event) $Event->delete();
|
||||||
// Event->delete() will do it all, so cake doesn't have to do anything.
|
// Event->delete() will do it all, so cake doesn't have to do anything.
|
||||||
return false;
|
return false;
|
||||||
} // end function afterDelete
|
} // end function afterDelete
|
||||||
|
|
Loading…
Reference in New Issue