function imce_mkdir_rmdir_batch in IMCE Mkdir 6
Same name and namespace in other branches
- 7 imce_mkdir.inc \imce_mkdir_rmdir_batch()
Batch remove directories.
1 call to imce_mkdir_rmdir_batch()
- imce_mkdir_rmdir_submit in ./
imce_mkdir.inc - Submit rmdir form.
File
- ./
imce_mkdir.inc, line 112
Code
function imce_mkdir_rmdir_batch(&$imce, $dirnames = array()) {
if (!isset($imce['dirremoved'])) {
$imce['dirremoved'] = array();
}
$parent = file_directory_path() . ($imce['dir'] == '.' ? '' : '/' . $imce['dir']);
$prefix = $imce['dir'] == '.' ? '' : $imce['dir'] . '/';
foreach ($dirnames as $dirname) {
$index = array_search($dirname, $imce['subdirectories']);
if ($index === FALSE) {
drupal_set_message(t('Subdirectory %dir does not exist.', array(
'%dir' => $dirname,
)), 'error');
continue;
}
if (isset($imce['directories'][$prefix . $dirname])) {
drupal_set_message(t('Subdirectory %dir is a predefined directory and can not be removed.', array(
'%dir' => $dirname,
)), 'error');
continue;
}
$dirpath = $parent . '/' . $dirname;
if (!imce_mkdir_rmdir_recursive($dirpath)) {
drupal_set_message(t('Subdirectory %dir could not be removed.', array(
'%dir' => $dirname,
)), 'error');
continue;
}
drupal_set_message(t('Subdirectory %dir has been removed.', array(
'%dir' => $dirname,
)));
$imce['dirremoved'] = array_merge($imce['dirremoved'], array_splice($imce['subdirectories'], $index, 1));
}
}