/** * Retrieves the default Sydney_Search_Files_Links instance. * * @return Sydney_Search_Files_Links */ public static function getInstance() { if (self::$_links === null) { self::$_links = new Sydney_Search_Files_Links(); } return self::$_links; }
/** * Delete a file with the ID passed as param. * URL example : http://<url>/adminfile/services/deletefiles/format/json/id/5 * @return the result in the format requested */ public function deletefileAction() { $r = $this->getRequest(); $this->view->ResultSet = array('status' => 0, 'message' => 'Undefined Error ' . $r->id); if (isset($r->id)) { $id = $r->id; $fdb = new Filfiles(); $where = 'id = ' . $id . ' AND safinstances_id = ' . $this->safinstancesId; $files = $fdb->fetchAll($where); if (count($files) == 1) { $f = $files[0]; if (Sydney_Search_Files_Links::getInstance()->isLinked($id)) { $this->view->ResultSet = array('status' => 0, 'message' => 'The file has linked into content and could not be delete from the database.'); $this->view->ResultSet['showtime'] = 5; } elseif ($fdb->delete($where)) { /* * GDE : 27/08/2010 * Add trace of current action */ Sydney_Db_Trace::add('trace.event.delete_file' . ' [' . $f->filename . ']', 'adminfiles', Sydney_Tools::getTableName($fdb), 'deletefile', $id); // */ $fullpath = Sydney_Tools_Paths::getAppdataPath() . '/adminfiles/' . $f->type . '/' . $f->filename; if (unlink($fullpath)) { $this->view->ResultSet = array('status' => 1, 'message' => 'File ' . $f->label . ' deleted', 'modal' => false); } else { $this->view->ResultSet = array('status' => 0, 'message' => 'The file could not be delete on the hard disk.'); $this->view->ResultSet['showtime'] = 5; } } else { $this->view->ResultSet = array('status' => 0, 'message' => 'The file could not be delete from the database.'); $this->view->ResultSet['showtime'] = 5; } } } }
public function indexAction() { $this->view->links = Sydney_Search_Files_Links::getInstance()->getLinks($this->getRequest()->fileid); }