You are here

function imce_settings_user in IMCE 5

get current user's settings

2 calls to imce_settings_user()
imce_browse in ./imce.module
Image Browser.
imce_menu in ./imce.module
Implementation of hook_menu().

File

./imce.module, line 459

Code

function imce_settings_user() {
  global $user;
  if ($user->uid == 1) {
    $set = imce_settings_user1();
  }
  else {
    $settings = variable_get('imce_settings_roles', array());
    foreach (imce_sorted_roles() as $rid => $name) {
      if (isset($user->roles[$rid]) && is_array($settings[$rid])) {
        $set = $settings[$rid];
        break;
      }
    }
  }
  $set = $set ? $set : imce_settings_default();
  $set['uid'] = $user->uid;
  $set['root'] = imce_get_directory($set);
  if ($_SESSION['imceuser']) {
    $settings = variable_get('imce_settings_roles', array());
    foreach (imce_sorted_roles() as $rid => $name) {
      if (isset($_SESSION['imceuser']['roles'][$rid]) && is_array($settings[$rid])) {
        $userset = $settings[$rid];
        break;
      }
    }
    $userset = $userset ? $userset : imce_settings_default();
    $userset['uid'] = $_SESSION['imceuser']['uid'];
    if ($_SESSION['imceuser']['ownperm']) {
      $set = $userset;
    }
    $set['root'] = imce_get_directory($userset);
  }
  $set['dir'] = $set['subnav'] && $_SESSION['imcedir'] && file_check_location(file_directory_path() . '/' . $_SESSION['imcedir'], $set['root']) ? file_directory_path() . '/' . $_SESSION['imcedir'] : $set['root'];
  return $set;
}