diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index 519f575d8b9..e10b84bb5d0 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -67,8 +67,15 @@ if ($_POST["action"]=='purge') { //print "x ".$filesarray[$key]['fullname']."
\n"; $count+=dol_delete_dir_recursive($filesarray[$key]['fullname']); - } - + } + + // Update cachenbofdoc + if ($conf->ecm->enabled && $_POST["choice"]=='allfiles') + { + require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php"); + $ecmdirstatic = new ECMDirectory($db); + $result = $ecmdirstatic->refreshcachenboffile(1); + } } if ($count) $message=$langs->trans("PurgeNDirectoriesDeleted",$count); diff --git a/htdocs/ecm/ecmdirectory.class.php b/htdocs/ecm/ecmdirectory.class.php index eec686db9ca..340436d1d85 100644 --- a/htdocs/ecm/ecmdirectory.class.php +++ b/htdocs/ecm/ecmdirectory.class.php @@ -607,9 +607,10 @@ class EcmDirectory // extends CommonObject /** * \brief Refresh value for cachenboffile * \param directory Directory to scan + * \param all 0=refresh this id , 1=refresh this entity * \return int <0 if KO, Nb of files in directory if OK */ - function refreshcachenboffile() + function refreshcachenboffile($all=0) { global $conf; include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); @@ -622,8 +623,16 @@ class EcmDirectory // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - $sql.= " cachenbofdoc='".sizeof($filelist)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql.= " cachenbofdoc = '".sizeof($filelist)."'"; + if (empty($all)) + { + $sql.= " WHERE rowid = ".$this->id; + } + else + { + $sql.= " WHERE entity = ".$conf->entity; + } + dol_syslog("EcmDirectories::refreshcachenboffile sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql)