You are here

function imce_process_directories in IMCE 7

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_process_directories()
  2. 6 inc/page.inc \imce_process_directories()

Translate tokens and evaluate php in directory names.

Convert directories into an associative array (dirname => info)

1 call to imce_process_directories()
imce_initiate_profile in inc/imce.page.inc
Initiate and return configuration profile for the $user.

File

inc/imce.page.inc, line 921
Implements the file browser.

Code

function imce_process_directories(&$imce, $user) {
  $directories = $imce['directories'];
  $paths = array();
  $translate = array(
    '%uid' => $user->uid,
  );
  foreach ($directories as $directory) {
    if (substr($directory['name'], 0, 4) == 'php:') {
      $directory['name'] = eval(substr($directory['name'], 4));

      // The php may return an array of directories.
      if (is_array($directory['name'])) {
        foreach ($directory['name'] as $name) {
          $paths[$name] = array(
            'name' => $name,
          ) + $directory;
        }
        continue;
      }
    }
    else {
      $directory['name'] = strtr($directory['name'], $translate);
    }
    if ($directory['name']) {
      $paths[$directory['name']] = $directory;
    }
  }
  $imce['directories'] = $paths;
}