Add field ref into ecm_files table.
This commit is contained in:
parent
7aad6683fa
commit
728dd3f7b3
@ -232,7 +232,7 @@ class EcmFiles //extends CommonObject
|
|||||||
* Load object in memory from the database
|
* Load object in memory from the database
|
||||||
*
|
*
|
||||||
* @param int $id Id object
|
* @param int $id Id object
|
||||||
* @param string $ref Ref = md5 = label
|
* @param string $ref Not used yet. Will contains a hash id from filename+filepath
|
||||||
* @param string $fullpath Full path of file (relative path to document directory)
|
* @param string $fullpath Full path of file (relative path to document directory)
|
||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
@ -242,6 +242,7 @@ class EcmFiles //extends CommonObject
|
|||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
$sql .= ' t.rowid,';
|
$sql .= ' t.rowid,';
|
||||||
|
$sql .= " t.ref,";
|
||||||
$sql .= " t.label,";
|
$sql .= " t.label,";
|
||||||
$sql .= " t.entity,";
|
$sql .= " t.entity,";
|
||||||
$sql .= " t.filename,";
|
$sql .= " t.filename,";
|
||||||
@ -260,14 +261,15 @@ class EcmFiles //extends CommonObject
|
|||||||
$sql .= " t.acl";
|
$sql .= " t.acl";
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
$sql.= ' WHERE 1 = 1';
|
$sql.= ' WHERE 1 = 1';
|
||||||
|
/* Fetching this table depends on filepath+filename, it must not depends on entity
|
||||||
if (! empty($conf->multicompany->enabled)) {
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
$sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")";
|
||||||
}
|
}*/
|
||||||
if ($fullpath) {
|
if ($fullpath) {
|
||||||
$sql .= " AND t.filepath = '" . $this->db->escape(dirname($fullpath)) . "' AND t.filename = '".$this->db->escape(basename($fullpath))."'";
|
$sql .= " AND t.filepath = '" . $this->db->escape(dirname($fullpath)) . "' AND t.filename = '".$this->db->escape(basename($fullpath))."'";
|
||||||
}
|
}
|
||||||
elseif (null !== $ref) {
|
elseif (null !== $ref) {
|
||||||
$sql .= " AND t.label = '".$this->db->escape($ref)."'";
|
$sql .= " AND t.ref = '".$this->db->escape($ref)."'";
|
||||||
} else {
|
} else {
|
||||||
$sql .= ' AND t.rowid = ' . $id;
|
$sql .= ' AND t.rowid = ' . $id;
|
||||||
}
|
}
|
||||||
@ -279,7 +281,7 @@ class EcmFiles //extends CommonObject
|
|||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
|
$this->ref = $obj->ref;
|
||||||
$this->label = $obj->label;
|
$this->label = $obj->label;
|
||||||
$this->entity = $obj->entity;
|
$this->entity = $obj->entity;
|
||||||
$this->filename = $obj->filename;
|
$this->filename = $obj->filename;
|
||||||
@ -367,9 +369,10 @@ class EcmFiles //extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql.= ' WHERE 1 = 1';
|
$sql.= ' WHERE 1 = 1';
|
||||||
|
/* Fetching this table depends on filepath+filename, it must not depends on entity
|
||||||
if (! empty($conf->multicompany->enabled)) {
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
$sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")";
|
||||||
}
|
}*/
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
|
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_ecm_files ADD COLUMN ref varchar(128) AFTER rowid;
|
||||||
ALTER TABLE llx_ecm_files CHANGE COLUMN fullpath filepath varchar(255);
|
ALTER TABLE llx_ecm_files CHANGE COLUMN fullpath filepath varchar(255);
|
||||||
ALTER TABLE llx_ecm_files CHANGE COLUMN filepath filepath varchar(255);
|
ALTER TABLE llx_ecm_files CHANGE COLUMN filepath filepath varchar(255);
|
||||||
ALTER TABLE llx_ecm_files ADD COLUMN position integer;
|
ALTER TABLE llx_ecm_files ADD COLUMN position integer;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
--
|
--
|
||||||
-- This program is free software; you can redistribute it and/or modify
|
-- This program is free software; you can redistribute it and/or modify
|
||||||
-- it under the terms of the GNU General Public License as published by
|
-- it under the terms of the GNU General Public License as published by
|
||||||
@ -17,7 +17,7 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, entity);
|
ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename);
|
||||||
ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label);
|
ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label);
|
||||||
|
|
||||||
--ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); Disabled, mysql limits size of index
|
--ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); Disabled, mysql limits size of index
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
CREATE TABLE llx_ecm_files
|
CREATE TABLE llx_ecm_files
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
ref varchar(128), -- Not used yet. Will contains a hash id from filename+filepath
|
||||||
label varchar(64) NOT NULL, -- label contains a md5
|
label varchar(64) NOT NULL, -- label contains a md5
|
||||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
filepath varchar(255) NOT NULL, -- relative to dolibarr document dir. Example module/def
|
filepath varchar(255) NOT NULL, -- relative to dolibarr document dir. Example module/def
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user