You are here

function imce_initiate_profile in IMCE 6

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

Initiate and return configuration profile for the $user.

2 calls to imce_initiate_profile()
imce_content in inc/page.inc
Content of the file browser.
imce_js in inc/page.inc
Ajax operations. q=imce&jsop={op}

File

inc/page.inc, line 649

Code

function imce_initiate_profile($user) {

  //check user profile and translate tokens in directory paths and evaluate php paths.
  if ($imce = imce_user_profile($user)) {
    $imce['directories'] = imce_process_directories($imce['directories'], $user);
    if (!empty($imce['directories'])) {
      $imce['uid'] = (int) $user->uid;
      $imce['url'] = url($_GET['q']);
      $imce['clean'] = variable_get('clean_url', 0) == 1;
      $imce['prvt'] = variable_get('file_downloads', '') == FILE_DOWNLOADS_PRIVATE;
      $imce['furl'] = $imce['prvt'] ? url('system/files') : base_path() . file_directory_path();
      if (variable_get('imce_settings_absurls', 0)) {
        $imce['furl'] = $GLOBALS['base_root'] . $imce['furl'];
      }
      $imce['filesize'] *= 1048576;

      //convert from Mb to byte
      $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'];
        $imce['perm'] = $info;

        //copy permissions of the active directory.
        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 don\'t have access to any configuration profile to use the file browser!'), 'error');
  }
  return FALSE;
}