function imce_working_directory in IMCE 6.2
Same name and namespace in other branches
- 6 inc/page.inc \imce_working_directory()
- 7 inc/imce.page.inc \imce_working_directory()
Return an available directory for the profile.
1 call to imce_working_directory()
- imce_initiate_profile in inc/
imce.page.inc - Initiate and return configuration profile for the $user.
File
- inc/
imce.page.inc, line 829 - Implements the file browser.
Code
function imce_working_directory(&$imce) {
//Do not use session if there is only one directory assigned.
$sess = TRUE;
if (count($imce['directories']) < 2) {
$perms = reset($imce['directories']);
if (!isset($perms['subnav']) || !$perms['subnav']) {
$sess = FALSE;
}
}
//check GET.
if (isset($_GET['dir'])) {
if ($info = imce_directory_info($_GET['dir'], $imce)) {
if (imce_check_directory($_GET['dir'], $imce)) {
if ($sess) {
$_SESSION['imce_directory'] = rawurlencode($info['name']);
}
}
else {
$info = FALSE;
}
}
else {
imce_inaccessible_directory($_GET['dir'], $imce);
}
return $info;
}
//check session
if ($sess && isset($_SESSION['imce_directory'])) {
$dirname = rawurldecode($_SESSION['imce_directory']);
if ($info = imce_directory_info($dirname, $imce)) {
if (imce_check_directory($dirname, $imce)) {
return $info;
}
}
}
//or the whole list.
foreach ($imce['directories'] as $dirname => $info) {
$dirname = (string) $dirname;
if (imce_check_directory($dirname, $imce)) {
if ($sess) {
$_SESSION['imce_directory'] = rawurlencode($dirname);
}
return $info;
}
}
return FALSE;
}