public function delete($mediafile_id) { $base = strtolower($this->baseModel); $this->createView(); $this->loadBaseModel($mediafile_id); if ($action = $this->submitted(array('submitString' => 'delete'))) { Event::run('bluebox.deleteOnSubmit', $action); if ($action == self::SUBMIT_CONFIRM) { if (($mf = Doctrine::getTable('MediaFile')->findOneByMediafileId($mediafile_id, Doctrine::HYDRATE_ARRAY)) === NULL) { messge::set('Unable to delete media file.'); $this->exitQtipAjaxForm(); url::redirect(Router_Core::$controller); } else { kohana::log('debug', 'Found db entry to delete: ' . print_r($mf, TRUE)); while (($fullPath = $this->locateFile($mf)) !== FALSE) { $result = @unlink($fullPath); kohana::log('debug', 'Deleting ' . $fullPath . ' with result ' . ($result ? 'TRUE' : 'FALSE')); } Doctrine_Query::create()->delete('MediaFile')->where('mediafile_id = ?', $mf['mediafile_id'])->execute(); message::set('Removed ' . basename($mf['file'])); $this->returnQtipAjaxForm(NULL); url::redirect(Router_Core::$controller); } } else { if ($action == self::SUBMIT_DENY) { $this->exitQtipAjaxForm(); url::redirect(Router_Core::$controller); } } } $this->prepareDeleteView(NULL, $mediafile_id); }
public function download($uuid) { $this->auto_render = FALSE; if (($msg = Doctrine::getTable('VoicemailMessage')->findOneByUuid($uuid, Doctrine::HYDRATE_ARRAY)) === NULL) { messge::set('Unable to find voicemail message.'); return; } $file = $msg['file_path']; if (!file_exists($file)) { Kohana::log('error', 'Can\'t access file: ' . $file); return; } header("Content-type: audio/wav"); header('Content-Disposition: attachment; filename="voicemail.wav"'); header('Content-Length: ' . filesize($file)); readfile($file); die; }