You are here

function imce_process_directories in IMCE 6

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

Translate tokens and evaluate php in directory names. Return an associative array of directories (dirname => info)

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

File

inc/page.inc, line 716

Code

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

      //not using drupal_eval since we need $user to be accessible as it may be different from $GLOBALS['user']
      $directory['name'] = eval(substr($directory['name'], 4));

      //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;
    }
  }
  return $paths;
}