function canDeleteImage(&$field, $record, &$item)
 {
     // Retrieve available (and appropriate) images from the DB
     $db = JFactory::getDBO();
     $query = 'SELECT id' . ' FROM #__flexicontent_files' . ' WHERE filename=' . $db->Quote($record);
     $db->setQuery($query);
     $file_id = $db->loadResult();
     if (!$file_id) {
         return true;
     }
     $ignored['item_id'] = $item->id;
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . 'filemanager.php';
     $fm = new FlexicontentModelFilemanager();
     return $fm->candelete(array($file_id), $ignored);
 }
 function canDeleteFile(&$field, $file_id, &$item)
 {
     // Check file exists in DB
     $db = JFactory::getDBO();
     $query = 'SELECT id' . ' FROM #__flexicontent_files' . ' WHERE id=' . $db->Quote($file_id);
     $db->setQuery($query);
     $file_id = $db->loadResult();
     if (!$file_id) {
         return true;
     }
     $ignored['item_id'] = $item->id;
     $fm = new FlexicontentModelFilemanager();
     return $fm->candelete(array($file_id), $ignored);
 }