_get_dir_file_ids

Versions
5
_get_dir_file_ids($fid, $recursive = FALSE)

Return a list of file ids that are in the directory

Parameters

$fid The file id associated with the directory

$recursive Whether or not to list recursive directories and their files

Return value

: If there are files in the directory an array of file ids, else return FALSE

▾ 3 functions call _get_dir_file_ids()

uc_file_order in contributions/ubercart/uc_file/uc_file.module
Implementation of hook_order().
_file_table_action in contributions/ubercart/uc_file/uc_file.module
Perform a specified action on the uc_files table
_user_table_action in contributions/ubercart/uc_file/uc_file.module
Perform a specified action on the uc_file_users table

Code

contributions/ubercart/uc_file/uc_file.module, line 1373

<?php
function _get_dir_file_ids($fid, $recursive = FALSE) {
  $fids = array();
  $dir = db_result(db_query("SELECT filename FROM {uc_files} WHERE fid = %d", $fid));
  $files = db_query("SELECT * FROM {uc_files} WHERE filename LIKE LOWER('%s')", $dir .'%');

  while ($file = db_fetch_object($files)) {
    $filename_change = str_replace($dir, '', $file->filename);
    $filename = (substr($filename_change, 0, 1) == '/') ? substr($filename_change, 1) : $filename_change;
    if (!strpos($filename, '/') && !empty($filename)) {
      $fids[] = $file->fid;
    }
    elseif ($recursive && !empty($filename) && $filename_change != $file->filename) {
      $fids[] = $file->fid;
    }
  }

  return (empty($fids)) ? FALSE : $fids;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.