diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 8d1c5cd712c..82f83595537 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -82,9 +82,16 @@ else // For no ajax call dol_print_error($db,$ecmdir->error); exit; } + + $relativepath=$ecmdir->getRelativePath(); // Example 'mydir/' } - $relativepath=$ecmdir->getRelativePath(); - $upload_dir = $rootdirfordoc.'/'.$relativepath; + elseif (GETPOST('section_dir')) + { + $relativepath=GETPOST('section_dir'); + } + //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); + + $upload_dir = $rootdirfordoc.'/'.$relativepath; } if (empty($url)) @@ -226,7 +233,18 @@ if ($type == 'directory') { if ($module == 'medias') { - $relativepath=GETPOST('file','alpha'); + /* + $_POST is array like + 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) + 'action' => string 'file_manager' (length=12) + 'website' => string 'template' (length=8) + 'pageid' => string '124' (length=3) + 'section_dir' => string 'mydir/' (length=3) + 'section_id' => string '0' (length=1) + 'max_file_size' => string '2097152' (length=7) + 'sendit' => string 'Envoyer fichier' (length=15) + */ + $relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha'); if ($relativepath && $relativepath!= '/') $relativepath.='/'; $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 4b588751829..a55df4a1038 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -30,6 +30,7 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + if (! isset($mode) || $mode != 'noajax') // For ajax call { $res=@include '../../main.inc.php'; @@ -39,16 +40,26 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; + //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; } + $openeddir = GETPOST('openeddir'); $modulepart= GETPOST('modulepart'); $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() + + $preopened = GETPOST('preopened'); + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' } else // For no ajax call { + //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } + $openeddir = GETPOST('openeddir'); $modulepart= GETPOST('modulepart'); $selecteddir = GETPOST('dir'); + + $preopened = GETPOST('preopened'); + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php'; } @@ -58,8 +69,16 @@ $langs->load("ecm"); // Define fullpathselecteddir. $fullpathselecteddir=''; -if ($modulepart == 'ecm') $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); -if ($modulepart == 'medias') $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); +if ($modulepart == 'ecm') +{ + $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); + $fullpathopeneddir=$conf->ecm->dir_output.'/'.($openeddir != '/' ? $openeddir : ''); +} +if ($modulepart == 'medias') +{ + $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); + $fullpathopeneddir=$dolibarr_main_data_root.'/medias/'.($openeddir != '/' ? $openeddir : ''); +} // Security: @@ -87,20 +106,20 @@ if ($modulepart == 'medias') * View */ -if (! isset($mode) || $mode != 'noajax') +if (! isset($mode) || $mode != 'noajax') // if ajax mode { top_httphead(); } -//print ''."\n"; +//print ''."\n"; $userstatic=new User($db); $form=new Form($db); $ecmdirstatic = new EcmDirectory($db); -// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir +// Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); -// Try to find key into $sqltree +// Try to find selected dir id into $sqltree and save it into $current_ecmdir_id $current_ecmdir_id=-1; foreach($sqltree as $keycursor => $val) { @@ -113,6 +132,25 @@ foreach($sqltree as $keycursor => $val) if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { + +/** + * treeOutputForAbsoluteDir + * + * @param array $sqltree Sqltree + * @param string $selecteddir Selected dir + * @param string $fullpathselecteddir Full path of selected dir + * @param string $modulepart Modulepart + * @param string $websitekey Website key + * @param int $pageid Page id + * @return void + */ +function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid) +{ + global $db, $langs, $form; + + $ecmdirstatic = new EcmDirectory($db); + $userstatic = new User($db); + if (file_exists($fullpathselecteddir)) { $files = @scandir($fullpathselecteddir); @@ -172,7 +210,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE $nboffilesinsubdir=$langs->trans("Unknown"); } - print '\n"; } } - // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php) - // Because the content is reloaded by ajax call, we must also reenable some jquery hooks - print "\n\n"; - print ''; - echo "\n"; - - } - } - else print "PermissionDenied"; - } - // This ajax service is called only when a directory $selecteddir is opened but not when closed. //print '