You are here

function imce_initiate_profile in IMCE 7

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

Initiate and return configuration profile for the $user.

3 calls to imce_initiate_profile()
imce_content in inc/imce.page.inc
Returns the content of the file browser.
imce_js in inc/imce.page.inc
Ajax operations. q=imce&jsop={op}.
theme_imce_user_page in inc/imce.page.inc
Returns the html for user's file browser tab.

File

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

Code

function imce_initiate_profile($user, $scheme = NULL) {

  // Check user profile and translate tokens in directory paths
  // and evaluate php paths.
  if ($imce = imce_user_profile($user, $scheme)) {

    // Allow alteration of raw profile.
    foreach (variable_get('imce_custom_init', array()) as $func => $state) {
      if ($state && function_exists($func)) {
        $func($imce, $user);
      }
    }
    imce_process_directories($imce, $user);
    if (!empty($imce['directories'])) {
      $imce['uid'] = (int) $user->uid;
      $imce['url'] = check_url(url($_GET['q']));
      $imce['clean'] = variable_get('clean_url', 0) == 1;
      $imce['absurls'] = variable_get('imce_settings_absurls', 0) == 1;
      $imce['furl'] = file_create_url($imce['scheme'] . '://');

      // Convert from Mb to byte.
      $imce['filesize'] *= 1048576;
      $imce['quota'] *= 1048576;
      $imce['tuquota'] *= 1048576;
      $imce['filenum'] = (int) $imce['filenum'];

      // Check and set the active directory.
      if ($info = imce_working_directory($imce)) {
        $imce['direct'] = isset($imce['directories'][$info['name']]);
        $imce['directories'][$info['name']] = $info;
        $imce['dir'] = $info['name'];

        // Copy permissions of the active directory.
        $imce['perm'] = $info;
        unset($imce['perm']['name']);
      }
      else {
        drupal_set_message(t('Unable to get a working directory for the file browser!'), 'error');
        $imce['dir'] = FALSE;
        $imce['error'] = TRUE;
      }
      return $imce;
    }
    drupal_set_message(t('There is no valid directory specified for the file browser!'), 'error');
  }
  else {
    drupal_set_message(t('You do not have access to any configuration profile to use the file browser!'), 'error');
  }
  return FALSE;
}