} $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); } //print $_SESSION['dol_ecmexpandedsectionarray'].'<br>'; $nbofentries = 0; $oldvallevel = 0; $var = true; foreach ($sqltree as $key => $val) { $var = false; $ecmdirstatic->id = $val['id']; $ecmdirstatic->ref = $val['label']; // Refresh cache if (preg_match('/refresh/i', $action)) { $result = $ecmdirstatic->fetch($val['id']); $ecmdirstatic->ref = $ecmdirstatic->label; $result = $ecmdirstatic->refreshcachenboffile(0); $val['cachenbofdoc'] = $result; } //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']); // Define showline $showline = 0; // If directory is son of expanded directory, we show line if (in_array($val['id_mere'], $expandedsectionarray)) { $showline = 4; } elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) { $showline = 3; } elseif (preg_match('/' . $val['fullpath'] . '_/i', $fullpathselected . '_')) { $showline = 2; } elseif ($val['level'] < 2) { $showline = 1; }
/** * Purge files into directory of data files. * * @param string $choice Choice of purge mode ('tempfiles', 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfiles') * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ function purgeFiles($choice = 'tempfilesold') { global $conf, $langs, $dolibarr_main_data_root; dol_syslog("Utils::purgeFiles choice=" . $choice, LOG_DEBUG); require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $filesarray = array(); if (empty($choice)) { $choice = 'tempfilesold'; } if ($choice == 'tempfiles' || $choice == 'tempfilesold') { // Delete temporary files if ($dolibarr_main_data_root) { $filesarray = dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', '', '', 2); if ($choice == 'tempfilesold') { $now = dol_now(); foreach ($filesarray as $key => $val) { if ($val['date'] > $now - 24 * 3600) { unset($filesarray[$key]); } // Discard files not older than 24h } } } } if ($choice == 'allfiles') { // Delete all files if ($dolibarr_main_data_root) { $filesarray = dol_dir_list($dolibarr_main_data_root, "all", 0, '', 'install\\.lock$'); } } if ($choice == 'logfile') { // Define filelog to discard it from purge $filelog = ''; if (!empty($conf->syslog->enabled)) { $filelog = SYSLOG_FILE; $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); } $filesarray[] = array('fullname' => $filelog, 'type' => 'file'); } $count = 0; if (count($filesarray)) { foreach ($filesarray as $key => $value) { //print "x ".$filesarray[$key]['fullname']."<br>\n"; if ($filesarray[$key]['type'] == 'dir') { $count += dol_delete_dir_recursive($filesarray[$key]['fullname']); } elseif ($filesarray[$key]['type'] == 'file') { // If (file that is not logfile) or (if logfile with option logfile) if ($filesarray[$key]['fullname'] != $filelog || $choice == 'logfile') { $count += dol_delete_file($filesarray[$key]['fullname']) ? 1 : 0; } } } // Update cachenbofdoc if (!empty($conf->ecm->enabled) && $choice == 'allfiles') { require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php'; $ecmdirstatic = new EcmDirectory($this->db); $result = $ecmdirstatic->refreshcachenboffile(1); } } if ($count > 0) { $this->output = $langs->trans("PurgeNDirectoriesDeleted", $count); } else { $this->output = $langs->trans("PurgeNothingToDelete"); } //return $count; return 0; // This function can be called by cron so must return 0 if OK }