You are here

function imagepicker_get_userpath in Image Picker 6.2

Same name and namespace in other branches
  1. 7 imagepicker.module \imagepicker_get_userpath()
2 calls to imagepicker_get_userpath()
imagepicker_get_image_path in ./imagepicker.module
imagepicker_get_path in ./imagepicker.module
some common utilities

File

./imagepicker.module, line 885
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_get_userpath($userdir, $dirsep = '/') {
  global $user;
  $path = '';

  // old or new
  $fstype = variable_get('imagepicker_fstype', '');
  if ($fstype == 'alpha') {
    $username = !is_array($userdir) ? $user->name : $userdir['name'];
    $firstletter = drupal_strtolower(drupal_substr($username, 0, 1));
    $firstletter = preg_match('/^[a-z]$/', $firstletter) ? $firstletter : 'others';
    $path .= $firstletter . $dirsep . $username . $dirsep;
  }
  else {
    $useruid = !is_array($userdir) ? $user->uid : $userdir['uid'];
    $path .= $useruid . $dirsep;
  }
  return $path;
}