/** * Notifies the DAM about a deleted file or folder. * This will remove the file(s) from the index. * * @param string $filename Filename with path or a folder which have to have a trailing slash. * @param string $recyclerPath New path when item is moved to recycler. * @return void */ function notify_fileDeleted($filename, $recyclerPath = '') { if (is_array($row = tx_dam::meta_getDataForFile($filename, 'uid', true))) { $uid = $row['uid']; } if ($uid) { $fields_values = array(); $fields_values['uid'] = $uid; $fields_values['deleted'] = '1'; // file was moved to recycler if ($recyclerPath) { $org_filename = tx_dam::file_basename($filename); $path_parts = t3lib_div::split_fileref($recyclerPath); $new_filename = $path_parts['file']; $new_path = $path_parts['path']; if ($org_filename != $new_filename) { $fields_values['file_name'] = $new_filename; } if ($new_path) { $fields_values['file_path'] = tx_dam::path_makeRelative($new_path); } } else { // delete MM relations $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_mm_ref', 'tx_dam_mm_ref.uid_local=' . $uid); } tx_dam_db::insertUpdateData($fields_values); // set language overlays deleted $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam', 'l18n_parent=' . $uid, array('deleted' => 1)); # $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam', 'l18n_parent='.$uid); // todo: replace with full supported group concept -------------------- // todo: delete child elements and their MM-relation // files stay at their physical storage position (usually uploads/tx_dam/storage/_uid_/) $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dam', 'parent_id=' . intval($uid)); while ($childRow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) { $childUid = $childRow[0]; $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam', 'uid=' . $childUid, array('deleted' => 1)); $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_mm_ref', 'tx_dam_mm_ref.uid_local=' . $childUid); } // ------------------------------------ } elseif (preg_match('#/$#', $filename)) { tx_dam_db::updateFilePathSetDeleted($filename); } }