30 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $element =
'ecmfiles';
45 public $table_element =
'ecm_files';
50 public $picto =
'folder-open';
86 public $fullpath_orig;
111 public $gen_or_uploaded;
146 public $src_object_type;
151 public $src_object_id;
158 public $fields = array(
159 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
160 'ref' => array(
'type'=>
'varchar(128)',
'label'=>
'Ref',
'enabled'=>
'1',
'position'=>20,
'notnull'=>1,
'visible'=>-1,
'index'=>1,
'searchall'=>1,
'showoncombobox'=>
'1',
'validate'=>
'1',
'comment'=>
"contains hash from filename+filepath"),
161 'label' => array(
'type'=>
'varchar(128)',
'label'=>
'Label',
'enabled'=>
'1',
'position'=>30,
'notnull'=>0,
'visible'=>-1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"contains hash of file content"),
162 'share' => array(
'type'=>
'varchar(128)',
'label'=>
'Share',
'enabled'=>
'1',
'position'=>40,
'notnull'=>0,
'visible'=>-1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment' =>
"contains hash for file sharing"),
163 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => -1,
'position' => 50,
'index' => 1),
164 'filepath' => array(
'type'=>
'varchar(255)',
'label'=>
'FilePath',
'enabled'=>
'1',
'position'=>60,
'notnull'=>0,
'visible'=>0,
'searchall'=>0,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"relative to dolibarr document dir. Example module/def"),
165 'filename' => array(
'type'=>
'varchar(255)',
'label'=>
'FileName',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"file name only without any directory"),
166 'src_object_type' => array(
'type'=>
'varchar(64)',
'label'=>
'SourceType',
'enabled'=>
'1',
'position'=>80,
'notnull'=>0,
'visible'=>0,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"Source object type ('proposal', 'invoice', ...)"),
167 'src_object_id' => array(
'type' =>
'integer',
'label' =>
'SourceID',
'default' => 1,
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'position' => 90,
'index' => 1,
'comment' =>
"Source object id"),
168 'fullpath_orig' => array(
'type'=>
'varchar(750)',
'label'=>
'FullPathOrig',
'enabled'=>
'1',
'position'=>100,
'notnull'=>0,
'visible'=>0,
'searchall'=>0,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"full path of original filename, when file is uploaded from a local computer"),
169 'description' => array(
'type' =>
'text',
'label' =>
'Description',
'enabled' => 1,
'visible' => 0,
'position' => 110),
170 'keywords' => array(
'type'=>
'varchar(750)',
'label'=>
'Keywords',
'enabled'=>
'1',
'position'=>120,
'notnull'=>0,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"list of keywords, separated with comma. Must be limited to most important keywords."),
171 'cover' => array(
'type' =>
'text',
'label' =>
'Cover',
'enabled' => 1,
'visible' => 0,
'position' => 130,
'comment'=>
"is this file a file to use for a cover"),
172 'position' => array(
'type' =>
'integer',
'label' =>
'Position',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 140,
'index' => 1,
'comment' =>
"position of file among others"),
173 'gen_or_uploaded' => array(
'type'=>
'varchar(12)',
'label'=>
'GenOrUpload',
'enabled'=>
'1',
'position'=>150,
'notnull'=>0,
'visible'=>-1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"'generated' or 'uploaded'"),
174 'extraparams' => array(
'type'=>
'varchar(255)',
'label'=>
'ExtraParams',
'enabled'=>
'1',
'position'=>160,
'notnull'=>0,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment' =>
"for stocking other parameters with json format"),
175 'date_c' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
176 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
177 'fk_user_c' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserAuthor',
'enabled'=>
'1',
'position'=>510,
'notnull'=>1,
'visible'=>-2,
'foreignkey'=>
'user.rowid',),
178 'fk_user_m' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,),
179 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
180 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
181 'acl' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160,
'comment' =>
"for future permission 'per file'"),
211 if (isset($this->
ref)) {
212 $this->
ref = trim($this->
ref);
214 if (isset($this->label)) {
215 $this->label = trim($this->label);
217 if (isset($this->share)) {
218 $this->share = trim($this->share);
220 if (isset($this->entity)) {
221 $this->entity = (int) $this->entity;
223 if (isset($this->filename)) {
224 $this->filename = preg_replace(
'/\.noexe$/',
'', trim($this->filename));
226 if (isset($this->filepath)) {
227 $this->filepath = trim($this->filepath);
228 $this->filepath = preg_replace(
'/[\\/]+$/',
'', $this->filepath);
230 if (isset($this->fullpath_orig)) {
231 $this->fullpath_orig = trim($this->fullpath_orig);
236 if (isset($this->keywords)) {
237 $this->keywords = trim($this->keywords);
239 if (isset($this->cover)) {
240 $this->cover = trim($this->cover);
242 if (isset($this->gen_or_uploaded)) {
243 $this->gen_or_uploaded = trim($this->gen_or_uploaded);
245 if (isset($this->extraparams)) {
246 $this->extraparams = trim($this->extraparams);
248 if (isset($this->fk_user_c)) {
249 $this->fk_user_c = (int) $this->fk_user_c;
251 if (isset($this->fk_user_m)) {
252 $this->fk_user_m = (int) $this->fk_user_m;
254 if (isset($this->acl)) {
255 $this->acl = trim($this->acl);
257 if (isset($this->src_object_type)) {
258 $this->src_object_type = trim($this->src_object_type);
260 if (empty($this->date_c)) {
263 if (empty($this->date_m)) {
268 if (empty($this->
ref)) {
269 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
270 $this->
ref =
dol_hash($this->filepath.
'/'.$this->filename, 3);
276 $sql =
"SELECT MAX(position) as maxposition FROM ".MAIN_DB_PREFIX.$this->table_element;
277 $sql .=
" WHERE filepath ='".$this->db->escape($this->filepath).
"'";
279 $resql = $this->db->query(
$sql);
281 $obj = $this->db->fetch_object($resql);
282 $maxposition = (int) $obj->maxposition;
284 $this->errors[] =
'Error '.$this->db->lasterror();
287 $maxposition = $maxposition + 1;
289 $maxposition = $this->position;
293 if (empty($this->filename) || empty($this->filepath)) {
294 $this->errors[] =
'Bad property filename or filepath';
297 if (!isset($this->entity)) {
298 $this->entity = $conf->entity;
303 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.
'(';
310 $sql .=
'fullpath_orig,';
311 $sql .=
'description,';
315 $sql .=
'gen_or_uploaded,';
316 $sql .=
'extraparams,';
319 $sql .=
'fk_user_c,';
320 $sql .=
'fk_user_m,';
322 $sql .=
'src_object_type,';
323 $sql .=
'src_object_id';
324 $sql .=
') VALUES (';
325 $sql .=
" '".$this->db->escape($this->
ref).
"', ";
326 $sql .=
' '.(!isset($this->label) ?
'NULL' :
"'".$this->db->escape($this->label).
"'").
',';
327 $sql .=
' '.(!isset($this->share) ?
'NULL' :
"'".$this->db->escape($this->share).
"'").
',';
328 $sql .=
' '.((int) $this->entity).
',';
329 $sql .=
' '.(!isset($this->filename) ?
'NULL' :
"'".$this->db->escape($this->filename).
"'").
',';
330 $sql .=
' '.(!isset($this->filepath) ?
'NULL' :
"'".$this->db->escape($this->filepath).
"'").
',';
331 $sql .=
' '.(!isset($this->fullpath_orig) ?
'NULL' :
"'".$this->db->escape($this->fullpath_orig).
"'").
',';
333 $sql .=
' '.(!isset($this->keywords) ?
'NULL' :
"'".$this->db->escape($this->keywords).
"'").
',';
334 $sql .=
' '.(!isset($this->cover) ?
'NULL' :
"'".$this->db->escape($this->cover).
"'").
',';
335 $sql .=
' '.((int) $maxposition).
',';
336 $sql .=
' '.(!isset($this->gen_or_uploaded) ?
'NULL' :
"'".$this->db->escape($this->gen_or_uploaded).
"'").
',';
337 $sql .=
' '.(!isset($this->extraparams) ?
'NULL' :
"'".$this->db->escape($this->extraparams).
"'").
',';
338 $sql .=
" '".$this->db->idate($this->date_c).
"',";
339 $sql .=
' '.(!isset($this->date_m) ||
dol_strlen($this->date_m) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_m).
"'").
',';
340 $sql .=
' '.(!isset($this->fk_user_c) ? $user->id : $this->fk_user_c).
',';
341 $sql .=
' '.(!isset($this->fk_user_m) ?
'NULL' : $this->fk_user_m).
',';
342 $sql .=
' '.(!isset($this->acl) ?
'NULL' :
"'".$this->db->escape($this->acl).
"'").
',';
343 $sql .=
' '.(!isset($this->src_object_type) ?
'NULL' :
"'".$this->db->escape($this->src_object_type).
"'").
',';
344 $sql .=
' '.(!isset($this->src_object_id) ?
'NULL' : $this->src_object_id);
349 $resql = $this->db->query(
$sql);
352 if ($this->db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
353 $this->errors[] =
'Error DB_ERROR_RECORD_ALREADY_EXISTS : '.$this->db->lasterror();
355 $this->errors[] =
'Error '.$this->db->lasterror();
357 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
361 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
367 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_CREATE', $user);
377 $this->db->rollback();
399 public function fetch($id, $ref =
'', $relativepath =
'', $hashoffile =
'', $hashforshare =
'', $src_object_type =
'', $src_object_id = 0)
410 $sql .=
" t.entity,";
411 $sql .=
" t.filename,";
412 $sql .=
" t.filepath,";
413 $sql .=
" t.fullpath_orig,";
414 $sql .=
" t.description,";
415 $sql .=
" t.keywords,";
417 $sql .=
" t.position,";
418 $sql .=
" t.gen_or_uploaded,";
419 $sql .=
" t.extraparams,";
420 $sql .=
" t.date_c,";
421 $sql .=
" t.tms as date_m,";
422 $sql .=
" t.fk_user_c,";
423 $sql .=
" t.fk_user_m,";
424 $sql .=
' t.note_private,';
425 $sql .=
' t.note_public,';
427 $sql .=
" t.src_object_type,";
428 $sql .=
" t.src_object_id";
429 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
430 $sql .=
' WHERE 1 = 1';
436 $relativepathwithnoexe = preg_replace(
'/\.noexe$/',
'', $relativepath);
437 $sql .=
" AND t.filepath = '".$this->db->escape(dirname($relativepath)).
"'";
438 $filename = basename($relativepathwithnoexe);
439 if ($filename !=
'*') {
440 $sql .=
" AND t.filename = '".$this->db->escape($filename).
"'";
442 $sql .=
" AND t.entity = ".$conf->entity;
443 } elseif (!empty($ref)) {
444 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
445 $sql .=
" AND t.entity = ".$conf->entity;
446 } elseif (!empty($hashoffile)) {
447 $sql .=
" AND t.label = '".$this->db->escape($hashoffile).
"'";
448 $sql .=
" AND t.entity = ".$conf->entity;
449 } elseif (!empty($hashforshare)) {
450 if ($hashforshare !=
'shared') {
451 $sql .=
" AND t.share = '".$this->db->escape($hashforshare).
"'";
453 $sql .=
" AND t.share IS NOT NULL AND t.share <> ''";
456 } elseif ($src_object_type && $src_object_id) {
458 $sql .=
" AND t.src_object_type = '".$this->db->escape($src_object_type).
"' AND t.src_object_id = ".((int) $src_object_id);
459 $sql .=
" AND t.entity = ".((int) $conf->entity);
461 $sql .=
' AND t.rowid = '.((int) $id);
464 $this->db->plimit(1);
465 $this->db->order(
't.rowid',
'ASC');
467 $resql = $this->db->query(
$sql);
469 $numrows = $this->db->num_rows($resql);
471 $obj = $this->db->fetch_object($resql);
473 $this->
id = $obj->rowid;
474 $this->
ref = $obj->ref;
475 $this->label = $obj->label;
476 $this->share = $obj->share;
477 $this->entity = $obj->entity;
478 $this->filename = $obj->filename;
479 $this->filepath = $obj->filepath;
480 $this->fullpath_orig = $obj->fullpath_orig;
482 $this->keywords = $obj->keywords;
483 $this->cover = $obj->cover;
485 $this->gen_or_uploaded = $obj->gen_or_uploaded;
486 $this->extraparams = $obj->extraparams;
487 $this->date_c = $this->db->jdate($obj->date_c);
488 $this->date_m = $this->db->jdate($obj->date_m);
489 $this->fk_user_c = $obj->fk_user_c;
490 $this->fk_user_m = $obj->fk_user_m;
491 $this->note_private = $obj->note_private;
492 $this->note_public = $obj->note_public;
493 $this->acl = $obj->acl;
494 $this->src_object_type = $obj->src_object_type;
495 $this->src_object_id = $obj->src_object_id;
504 $this->db->free($resql);
512 $this->errors[] =
'Error '.$this->db->lasterror();
513 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
531 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
539 $sql .=
" t.entity,";
540 $sql .=
" t.filename,";
541 $sql .=
" t.filepath,";
542 $sql .=
" t.fullpath_orig,";
543 $sql .=
" t.description,";
544 $sql .=
" t.keywords,";
546 $sql .=
" t.position,";
547 $sql .=
" t.gen_or_uploaded,";
548 $sql .=
" t.extraparams,";
549 $sql .=
" t.date_c,";
550 $sql .=
" t.tms as date_m,";
551 $sql .=
" t.fk_user_c,";
552 $sql .=
" t.fk_user_m,";
554 $sql .=
" t.src_object_type,";
555 $sql .=
" t.src_object_id";
556 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
560 if (count($filter) > 0) {
561 foreach ($filter as $key => $value) {
562 if ($key ==
't.src_object_id') {
563 $sqlwhere[] = $key.
" = ".((int) $value);
565 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
569 $sql .=
' WHERE 1 = 1';
574 if (count($sqlwhere) > 0) {
575 $sql .=
' AND '.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere);
577 if (!empty($sortfield)) {
578 $sql .= $this->db->order($sortfield, $sortorder);
580 if (!empty($limit)) {
581 $sql .= $this->db->plimit($limit, $offset);
584 $this->lines = array();
586 $resql = $this->db->query(
$sql);
588 $num = $this->db->num_rows($resql);
590 while ($obj = $this->db->fetch_object($resql)) {
593 $line->id = $obj->rowid;
594 $line->ref = $obj->rowid;
595 $line->label = $obj->label;
596 $line->share = $obj->share;
597 $line->entity = $obj->entity;
598 $line->filename = $obj->filename;
599 $line->filepath = $obj->filepath;
600 $line->fullpath_orig = $obj->fullpath_orig;
601 $line->description = $obj->description;
602 $line->keywords = $obj->keywords;
603 $line->cover = $obj->cover;
604 $line->position = $obj->position;
605 $line->gen_or_uploaded = $obj->gen_or_uploaded;
606 $line->extraparams = $obj->extraparams;
607 $line->date_c = $this->db->jdate($obj->date_c);
608 $line->date_m = $this->db->jdate($obj->date_m);
609 $line->fk_user_c = $obj->fk_user_c;
610 $line->fk_user_m = $obj->fk_user_m;
611 $line->acl = $obj->acl;
612 $line->src_object_type = $obj->src_object_type;
613 $line->src_object_id = $obj->src_object_id;
614 $this->lines[] = $line;
616 $this->db->free($resql);
620 $this->errors[] =
'Error '.$this->db->lasterror();
621 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
645 if (isset($this->
ref)) {
646 $this->
ref = trim($this->
ref);
648 if (isset($this->label)) {
649 $this->label = trim($this->label);
651 if (isset($this->share)) {
652 $this->share = trim($this->share);
654 if (isset($this->entity)) {
655 $this->entity = trim($this->entity);
657 if (isset($this->filename)) {
658 $this->filename = preg_replace(
'/\.noexe$/',
'', trim($this->filename));
660 if (isset($this->filepath)) {
661 $this->filepath = trim($this->filepath);
662 $this->filepath = preg_replace(
'/[\\/]+$/',
'', $this->filepath);
664 if (isset($this->fullpath_orig)) {
665 $this->fullpath_orig = trim($this->fullpath_orig);
670 if (isset($this->keywords)) {
671 $this->keywords = trim($this->keywords);
673 if (isset($this->cover)) {
674 $this->cover = trim($this->cover);
676 if (isset($this->gen_or_uploaded)) {
677 $this->gen_or_uploaded = trim($this->gen_or_uploaded);
679 if (isset($this->extraparams)) {
680 $this->extraparams = trim($this->extraparams);
682 if (isset($this->fk_user_m)) {
683 $this->fk_user_m = trim($this->fk_user_m);
685 if (isset($this->acl)) {
686 $this->acl = trim($this->acl);
688 if (isset($this->src_object_type)) {
689 $this->src_object_type = trim($this->src_object_type);
696 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET';
697 $sql .=
" ref = '".$this->db->escape(
dol_hash($this->filepath.
"/".$this->filename, 3)).
"',";
698 $sql .=
' label = '.(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
',';
699 $sql .=
' share = '.(!empty($this->share) ?
"'".$this->db->escape($this->share).
"'" :
"null").
',';
700 $sql .=
' entity = '.(isset($this->entity) ? $this->entity : $conf->entity).
',';
701 $sql .=
' filename = '.(isset($this->filename) ?
"'".$this->db->escape($this->filename).
"'" :
"null").
',';
702 $sql .=
' filepath = '.(isset($this->filepath) ?
"'".$this->db->escape($this->filepath).
"'" :
"null").
',';
703 $sql .=
' fullpath_orig = '.(isset($this->fullpath_orig) ?
"'".$this->db->escape($this->fullpath_orig).
"'" :
"null").
',';
705 $sql .=
' keywords = '.(isset($this->keywords) ?
"'".$this->db->escape($this->keywords).
"'" :
"null").
',';
706 $sql .=
' cover = '.(isset($this->cover) ?
"'".$this->db->escape($this->cover).
"'" :
"null").
',';
708 $sql .=
' gen_or_uploaded = '.(isset($this->gen_or_uploaded) ?
"'".$this->db->escape($this->gen_or_uploaded).
"'" :
"null").
',';
709 $sql .=
' extraparams = '.(isset($this->extraparams) ?
"'".$this->db->escape($this->extraparams).
"'" :
"null").
',';
710 $sql .=
' date_c = '.(!isset($this->date_c) ||
dol_strlen($this->date_c) != 0 ?
"'".$this->db->idate($this->date_c).
"'" :
'null').
',';
712 $sql .=
' fk_user_m = '.($this->fk_user_m > 0 ? $this->fk_user_m : $user->id).
',';
713 $sql .=
' acl = '.(isset($this->acl) ?
"'".$this->db->escape($this->acl).
"'" :
"null").
',';
714 $sql .=
' src_object_id = '.($this->src_object_id > 0 ? $this->src_object_id :
"null").
',';
715 $sql .=
' src_object_type = '.(isset($this->src_object_type) ?
"'".$this->db->escape($this->src_object_type).
"'" :
"null");
716 $sql .=
' WHERE rowid='.((int) $this->
id);
720 $resql = $this->db->query(
$sql);
723 $this->errors[] =
'Error '.$this->db->lasterror();
724 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
728 if (!$error && !$notrigger) {
730 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_MODIFY', $user);
739 $this->db->rollback();
757 public function delete(
User $user, $notrigger =
false)
768 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_DELETE', $user);
779 dol_syslog(get_class($this).
"::delete error ".$this->error, LOG_ERR);
784 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
785 $sql .=
' WHERE rowid='.((int) $this->
id);
787 $resql = $this->db->query(
$sql);
790 $this->errors[] =
'Error '.$this->db->lasterror();
791 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
797 $this->db->rollback();
819 $object =
new Ecmfiles($this->db);
824 $object->fetch($fromid);
832 $object->context[
'createfromclone'] =
'createfromclone';
833 $result = $object->create($user);
838 $this->errors = $object->errors;
839 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
842 unset($object->context[
'createfromclone']);
850 $this->db->rollback();
866 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'')
868 global $db, $conf, $langs;
869 global $dolibarr_main_authentication, $dolibarr_main_demo;
870 global $menumanager, $hookmanager;
872 if (!empty($conf->dol_no_mouse_hover)) {
878 $label =
'<u>'.$langs->trans(
"MyModule").
'</u>';
880 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
882 $url = DOL_URL_ROOT.
'/ecm/'.$this->table_name.
'_card.php?id='.$this->id;
885 if (empty($notooltip)) {
886 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
887 $label = $langs->trans(
"ShowProject");
888 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
890 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
891 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
893 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
896 $linkstart =
'<a href="'.$url.
'"';
897 $linkstart .= $linkclose.
'>';
901 $result .= ($linkstart.img_object(($notooltip ?
'' : $label),
'label', ($notooltip ?
'' :
'class="classfortooltip"')).$linkend);
902 if ($withpicto != 2) {
906 $result .= $linkstart.$this->ref.$linkend;
909 $hookmanager->initHooks(array($this->element .
'dao'));
910 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
911 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
913 $result = $hookmanager->resPrint;
915 $result .= $hookmanager->resPrint;
928 return $this->
LibStatut($this->status, $mode);
959 $this->label =
'0a1b2c3e4f59999999';
961 $this->filename =
'myspecimenfilefile.pdf';
962 $this->filepath =
'/aaa/bbb';
963 $this->fullpath_orig =
'c:/file on my disk.pdf';
964 $this->
description =
'This is a long description of file';
965 $this->keywords =
'key1,key2';
968 $this->gen_or_uploaded =
'uploaded';
969 $this->extraparams =
'';
970 $this->date_c = (
dol_now() - 3600 * 24 * 10);
972 $this->fk_user_c = $user->id;
973 $this->fk_user_m =
'';
975 $this->src_object_type =
'product';
976 $this->src_object_id = 1;
998 public $fullpath_orig;
1003 public $description;
1008 public $gen_or_uploaded;
1009 public $extraparams;
1010 public $date_c =
'';
1011 public $date_m =
'';
1024 public $src_object_type;
1025 public $src_object_id;