Example #1
0
/**
 * Rename evocache folders after File settings update, whe evocahe folder name was chaned
 *
 * @param string old evocache folder name
 * @param string new evocache folder name
 * @return bool true on success
 */
function rename_cachefolders($oldname, $newname)
{
    $available_Roots = FileRootCache::get_available_FileRoots();
    $slash_oldname = '/' . $oldname;
    $result = true;
    foreach ($available_Roots as $fileRoot) {
        $filename_params = array('inc_files' => false, 'inc_evocache' => true);
        $dirpaths = get_filenames($fileRoot->ads_path, $filename_params);
        foreach ($dirpaths as $dirpath) {
            // search ?evocache folders
            $dirpath_length = strlen($dirpath);
            if ($dirpath_length < 10) {
                // The path is to short, can not contains ?evocache folder name
                continue;
            }
            // searching at the end of the path -> '/' character + ?evocache, length = 1 + 9
            $path_end = substr($dirpath, $dirpath_length - 10);
            if ($path_end == $slash_oldname) {
                // this is a ?evocache folder
                $new_dirpath = substr_replace($dirpath, $newname, $dirpath_length - 9);
                // result is true only if all rename call return true (success)
                $result = $result && @rename($dirpath, $new_dirpath);
            }
        }
    }
    return $result;
}
</button>
						<?php 
    }
    $Form->end_form();
    echo '</div>';
}
?>

			<!-- ROOTS SELECT -->

			<?php 
$Form = new Form(NULL, 'fmbar_roots', 'post', 'none');
$Form->begin_form();
// $Form->hidden_ctrl();
$Form->hiddens_by_key(get_memorized());
$rootlist = FileRootCache::get_available_FileRoots(get_param('root'));
if (count($rootlist) > 1) {
    // provide list of roots to choose from
    ?>
					<select name="new_root" onchange="this.form.submit();">
					<?php 
    $optgroup = '';
    foreach ($rootlist as $l_FileRoot) {
        if (!$current_User->check_perm('files', 'view', false, $l_FileRoot)) {
            continue;
        }
        if (($typegroupname = $l_FileRoot->get_typegroupname()) != $optgroup) {
            // We're entering a new group:
            if (!empty($optgroup)) {
                echo '</optgroup>';
            }