Fix: refresh nb of documents in ecm table after delete all files
This commit is contained in:
parent
236ef9a70f
commit
9cc8f2fed8
@ -67,8 +67,15 @@ if ($_POST["action"]=='purge')
|
||||
{
|
||||
//print "x ".$filesarray[$key]['fullname']."<br>\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);
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user