You are here

function search_files_attachments_nodeapi in Search Files 6.2

Implementation of hook_nodeapi().

File

./search_files_attachments.module, line 12
Used to index files in attachments

Code

function search_files_attachments_nodeapi(&$node, $op) {
  switch ($op) {
    case 'delete':

      // Remove any files from the search index
      if (!empty($node->files)) {
        foreach ($node->files as $fid) {
          if (is_object($fid)) {
            $fid = get_object_vars($fid);
          }
          search_wipe($fid['fid'], 'search_files_att');
        }
      }
      break;
    case 'presave':

      // Remove files from the search index if needed.
      if (!empty($node->files)) {
        foreach ($node->files as $fid) {
          if (is_object($fid)) {
            $fid = get_object_vars($fid);
          }
          if ($fid['remove'] == 1) {
            search_wipe($fid['fid'], 'search_files_att');
          }
        }
      }
      break;
  }
}