NEW Uploaded files are indexed into database
This commit is contained in:
parent
ed0ffd6f5a
commit
26098082d0
@ -997,11 +997,41 @@ class FormFile
|
|||||||
$filearray[$key]['position']=999999; // File not indexed are at end. So if we add a file, it will not replace an existing position
|
$filearray[$key]['position']=999999; // File not indexed are at end. So if we add a file, it will not replace an existing position
|
||||||
$filearray[$key]['cover']=0;
|
$filearray[$key]['cover']=0;
|
||||||
$filearray[$key]['acl']='';
|
$filearray[$key]['acl']='';
|
||||||
$filearray[$key]['rowid']=0;
|
|
||||||
// TODO Add entry into database
|
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']);
|
||||||
|
if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
|
||||||
//...
|
{
|
||||||
|
dol_syslog("list_of_documents We found a file not indexed into database. We add it");
|
||||||
|
include DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||||
|
$ecmfile=new EcmFiles($this->db);
|
||||||
|
|
||||||
|
// Add entry into database
|
||||||
|
$filename = basename($rel_filename);
|
||||||
|
$rel_dir = dirname($rel_filename);
|
||||||
|
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||||
|
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||||
|
|
||||||
|
$ecmfile->filepath = $rel_dir;
|
||||||
|
$ecmfile->filename = $filename;
|
||||||
|
$ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file
|
||||||
|
$ecmfile->fullpath_orig = $filearray[$key]['fullname'];
|
||||||
|
$ecmfile->gen_or_uploaded = 'unknown';
|
||||||
|
$ecmfile->description = ''; // indexed content
|
||||||
|
$ecmfile->keyword = ''; // keyword content
|
||||||
|
$result = $ecmfile->create($user);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filearray[$key]['rowid']=$result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filearray[$key]['rowid']=0; // Should not happened
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -652,7 +652,6 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
|
|||||||
{
|
{
|
||||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||||
}
|
}
|
||||||
$result = $ecmfile->create($user);
|
|
||||||
}
|
}
|
||||||
elseif ($result < 0)
|
elseif ($result < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,6 +29,7 @@ $table_element_line=(empty($table_element_line)?$object->table_element_line:$tab
|
|||||||
$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines)));
|
$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines)));
|
||||||
$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
|
$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
|
||||||
$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
|
$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
|
||||||
|
$filepath=(empty($filepath)?'':$filepath);
|
||||||
|
|
||||||
if (GETPOST('action') != 'editline' && $nboflines > 1) { ?>
|
if (GETPOST('action') != 'editline' && $nboflines > 1) { ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -48,12 +49,14 @@ $(document).ready(function(){
|
|||||||
var table_element_line = "<?php echo $table_element_line; ?>";
|
var table_element_line = "<?php echo $table_element_line; ?>";
|
||||||
var fk_element = "<?php echo $fk_element; ?>";
|
var fk_element = "<?php echo $fk_element; ?>";
|
||||||
var element_id = "<?php echo $id; ?>";
|
var element_id = "<?php echo $id; ?>";
|
||||||
|
var filepath = "<?php echo urlencode($filepath); ?>";
|
||||||
$.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
|
$.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
|
||||||
{
|
{
|
||||||
roworder: roworder,
|
roworder: roworder,
|
||||||
table_element_line: table_element_line,
|
table_element_line: table_element_line,
|
||||||
fk_element: fk_element,
|
fk_element: fk_element,
|
||||||
element_id: element_id
|
element_id: element_id,
|
||||||
|
filepath: filepath
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
if (reloadpage == 1) {
|
if (reloadpage == 1) {
|
||||||
|
|||||||
@ -203,7 +203,8 @@ class EcmFiles //extends CommonObject
|
|||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
||||||
|
$this->position = $maxposition;
|
||||||
|
|
||||||
if (!$notrigger) {
|
if (!$notrigger) {
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
// want this action to call a trigger.
|
// want this action to call a trigger.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user