function imce_user_profile in IMCE 7
Same name and namespace in other branches
- 6.2 imce.module \imce_user_profile()
- 6 imce.module \imce_user_profile()
Returns the configuration profile.
Returns the configuration profile assigned to a user for a specific file scheme.
3 calls to imce_user_profile()
- imce_access in ./
imce.module - Checks if the user is assigned an imce profile.
- imce_initiate_profile in inc/
imce.page.inc - Initiate and return configuration profile for the $user.
- imce_user_page_access in ./
imce.module - Checks access to user/{$account->uid}/imce for the $user.
File
- ./
imce.module, line 184 - Implements the necessary hooks for the file browser to work properly.
Code
function imce_user_profile($user, $scheme = NULL) {
static $ups = array();
// Set scheme.
if (empty($scheme)) {
$scheme = variable_get('file_default_scheme', 'public');
}
// Return from cache.
if (isset($ups[$scheme][$user->uid])) {
return $ups[$scheme][$user->uid];
}
$ups[$scheme][$user->uid] = FALSE;
// Check scheme.
$swrappers = file_get_stream_wrappers();
if (!isset($swrappers[$scheme])) {
return FALSE;
}
$profiles = variable_get('imce_profiles', array());
$scinfo = array(
'scheme' => $scheme,
);
// Handle user#1 separately.
if ($user->uid == 1) {
return $ups[$scheme][$user->uid] = isset($profiles[1]) ? $profiles[1] + $scinfo : FALSE;
}
// Handle regular users.
$roles_profiles = variable_get('imce_roles_profiles', array());
$sckey = $scheme . '_pid';
foreach ($roles_profiles as $rid => $conf) {
if (isset($user->roles[$rid]) && isset($conf[$sckey]) && isset($profiles[$conf[$sckey]])) {
return $ups[$scheme][$user->uid] = $profiles[$conf[$sckey]] + $scinfo;
}
}
return FALSE;
}