knowledgerecord.class.php 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/knowledgemanagement/class/knowledgerecord.class.php
  19. * \ingroup knowledgemanagement
  20. * \brief This file is a CRUD class file for KnowledgeRecord (Create/Read/Update/Delete)
  21. */
  22. // Put here all includes required by your class file
  23. require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
  24. //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
  25. //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
  26. /**
  27. * Class for KnowledgeRecord
  28. */
  29. class KnowledgeRecord extends CommonObject
  30. {
  31. /**
  32. * @var string ID of module.
  33. */
  34. public $module = 'knowledgemanagement';
  35. /**
  36. * @var string ID to identify managed object.
  37. */
  38. public $element = 'knowledgerecord';
  39. /**
  40. * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
  41. */
  42. public $table_element = 'knowledgemanagement_knowledgerecord';
  43. /**
  44. * @var int Does this object support multicompany module ?
  45. * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
  46. */
  47. public $ismultientitymanaged = 1;
  48. /**
  49. * @var int Does object support extrafields ? 0=No, 1=Yes
  50. */
  51. public $isextrafieldmanaged = 1;
  52. /**
  53. * @var string String with name of icon for knowledgerecord. Must be the part after the 'object_' into object_knowledgerecord.png
  54. */
  55. public $picto = 'knowledgemanagement';
  56. const STATUS_DRAFT = 0;
  57. const STATUS_VALIDATED = 1;
  58. const STATUS_CANCELED = 9;
  59. /**
  60. * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:SortField]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
  61. * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
  62. * 'label' the translation key.
  63. * 'picto' is code of a picto to show before value in forms
  64. * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
  65. * 'position' is the sort order of field.
  66. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
  67. * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
  68. * 'noteditable' says if field is not editable (1 or 0)
  69. * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
  70. * 'index' if we want an index in database.
  71. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
  72. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
  73. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
  74. * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200'
  75. * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
  76. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
  77. * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
  78. * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
  79. * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
  80. * 'comment' is not used. You can store here any text of your choice. It is not used by application.
  81. * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
  82. *
  83. * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
  84. */
  85. // BEGIN MODULEBUILDER PROPERTIES
  86. /**
  87. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
  88. */
  89. public $fields=array(
  90. 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
  91. 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'visible'=>5, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", "csslist"=>"nowraponall", "showoncombobox"=>1),
  92. 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>20, 'index'=>1),
  93. 'question' => array('type'=>'text', 'label'=>'Question', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'csslist'=>'tdoverflowmax300', 'copytoclipboard'=>1, 'tdcss'=>'titlefieldcreate nowraponall'),
  94. 'lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>1, 'tdcss'=>'titlefieldcreate nowraponall', "csslist"=>"tdoverflowmax100"),
  95. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
  96. 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>2,),
  97. 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
  98. 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserCreation', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
  99. 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
  100. 'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>'1', 'position'=>512, 'notnull'=>0, 'visible'=>-2,),
  101. 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
  102. 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
  103. //'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'),
  104. 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php:0:(t.active:=:1):pos', 'label'=>'SuggestedForTicketsInGroup', 'enabled'=>'isModEnabled("ticket")', 'position'=>520, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory', 'csslist'=>'minwidth200 tdoverflowmax250'),
  105. 'answer' => array('type'=>'html', 'label'=>'Solution', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>3, 'searchall'=>1, 'csslist'=>'tdoverflowmax300', 'copytoclipboard'=>1, 'tdcss'=>'titlefieldcreate nowraponall'),
  106. 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>5, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Obsolete'),),
  107. );
  108. public $rowid;
  109. public $ref;
  110. public $entity;
  111. public $date_creation;
  112. public $tms;
  113. public $last_main_doc;
  114. public $fk_user_creat;
  115. public $fk_user_modif;
  116. public $fk_user_valid;
  117. public $import_key;
  118. public $model_pdf;
  119. public $question;
  120. public $answer;
  121. public $url;
  122. public $status;
  123. public $lang;
  124. // END MODULEBUILDER PROPERTIES
  125. // If this object has a subtable with lines
  126. // /**
  127. // * @var string Name of subtable line
  128. // */
  129. // public $table_element_line = 'knowledgemanagement_knowledgerecordline';
  130. // /**
  131. // * @var string Field with ID of parent key if this object has a parent
  132. // */
  133. // public $fk_element = 'fk_knowledgerecord';
  134. // /**
  135. // * @var string Name of subtable class that manage subtable lines
  136. // */
  137. // public $class_element_line = 'KnowledgeRecordline';
  138. // /**
  139. // * @var array List of child tables. To test if we can delete object.
  140. // */
  141. // protected $childtables = array();
  142. // /**
  143. // * @var array List of child tables. To know object to delete on cascade.
  144. // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
  145. // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
  146. // */
  147. // protected $childtablesoncascade = array('knowledgemanagement_knowledgerecorddet');
  148. // /**
  149. // * @var KnowledgeRecordLine[] Array of subtable lines
  150. // */
  151. // public $lines = array();
  152. /**
  153. * Constructor
  154. *
  155. * @param DoliDb $db Database handler
  156. */
  157. public function __construct(DoliDB $db)
  158. {
  159. global $conf, $langs;
  160. $this->db = $db;
  161. if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
  162. $this->fields['rowid']['visible'] = 0;
  163. }
  164. if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
  165. $this->fields['entity']['enabled'] = 0;
  166. }
  167. // Example to show how to set values of fields definition dynamically
  168. /*if ($user->rights->knowledgemanagement->knowledgerecord->read) {
  169. $this->fields['myfield']['visible'] = 1;
  170. $this->fields['myfield']['noteditable'] = 0;
  171. }*/
  172. // Unset fields that are disabled
  173. foreach ($this->fields as $key => $val) {
  174. if (isset($val['enabled']) && empty($val['enabled'])) {
  175. unset($this->fields[$key]);
  176. }
  177. }
  178. // Translate some data of arrayofkeyval
  179. if (is_object($langs)) {
  180. foreach ($this->fields as $key => $val) {
  181. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  182. foreach ($val['arrayofkeyval'] as $key2 => $val2) {
  183. $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
  184. }
  185. }
  186. }
  187. }
  188. }
  189. /**
  190. * Create object into database
  191. *
  192. * @param User $user User that creates
  193. * @param bool $notrigger false=launch triggers after, true=disable triggers
  194. * @return int <0 if KO, Id of created object if OK
  195. */
  196. public function create(User $user, $notrigger = false)
  197. {
  198. return $this->createCommon($user, $notrigger);
  199. }
  200. /**
  201. * Clone an object into another one
  202. *
  203. * @param User $user User that creates
  204. * @param int $fromid Id of object to clone
  205. * @return mixed New object created, <0 if KO
  206. */
  207. public function createFromClone(User $user, $fromid)
  208. {
  209. global $langs, $extrafields;
  210. $error = 0;
  211. dol_syslog(__METHOD__, LOG_DEBUG);
  212. $object = new self($this->db);
  213. $this->db->begin();
  214. // Load source object
  215. $result = $object->fetchCommon($fromid);
  216. if ($result > 0 && !empty($object->table_element_line)) {
  217. $object->fetchLines();
  218. }
  219. // get lines so they will be clone
  220. //foreach($this->lines as $line)
  221. // $line->fetch_optionals();
  222. // Reset some properties
  223. unset($object->id);
  224. unset($object->fk_user_creat);
  225. unset($object->import_key);
  226. // Clear fields
  227. if (property_exists($object, 'ref')) {
  228. $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
  229. }
  230. if (property_exists($object, 'label')) {
  231. $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
  232. }
  233. if (property_exists($object, 'status')) {
  234. $object->status = self::STATUS_DRAFT;
  235. }
  236. if (property_exists($object, 'date_creation')) {
  237. $object->date_creation = dol_now();
  238. }
  239. if (property_exists($object, 'date_modification')) {
  240. $object->date_modification = null;
  241. }
  242. // ...
  243. // Clear extrafields that are unique
  244. if (is_array($object->array_options) && count($object->array_options) > 0) {
  245. $extrafields->fetch_name_optionals_label($this->table_element);
  246. foreach ($object->array_options as $key => $option) {
  247. $shortkey = preg_replace('/options_/', '', $key);
  248. if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
  249. //var_dump($key);
  250. //var_dump($clonedObj->array_options[$key]); exit;
  251. unset($object->array_options[$key]);
  252. }
  253. }
  254. }
  255. // Create clone
  256. $object->context['createfromclone'] = 'createfromclone';
  257. $result = $object->createCommon($user);
  258. if ($result < 0) {
  259. $error++;
  260. $this->error = $object->error;
  261. $this->errors = $object->errors;
  262. }
  263. if (!$error) {
  264. // copy internal contacts
  265. if ($this->copy_linked_contact($object, 'internal') < 0) {
  266. $error++;
  267. }
  268. }
  269. if (!$error) {
  270. // copy external contacts if same company
  271. if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
  272. if ($this->copy_linked_contact($object, 'external') < 0) {
  273. $error++;
  274. }
  275. }
  276. }
  277. unset($object->context['createfromclone']);
  278. // End
  279. if (!$error) {
  280. $this->db->commit();
  281. return $object;
  282. } else {
  283. $this->db->rollback();
  284. return -1;
  285. }
  286. }
  287. /**
  288. * Load object in memory from the database
  289. *
  290. * @param int $id Id object
  291. * @param string $ref Ref
  292. * @return int <0 if KO, 0 if not found, >0 if OK
  293. */
  294. public function fetch($id, $ref = null)
  295. {
  296. $result = $this->fetchCommon($id, $ref);
  297. if ($result > 0 && !empty($this->table_element_line)) {
  298. $this->fetchLines();
  299. }
  300. return $result;
  301. }
  302. /**
  303. * Load object lines in memory from the database
  304. *
  305. * @return int <0 if KO, 0 if not found, >0 if OK
  306. */
  307. public function fetchLines()
  308. {
  309. $this->lines = array();
  310. $result = $this->fetchLinesCommon();
  311. return $result;
  312. }
  313. /**
  314. * Load list of objects in memory from the database.
  315. *
  316. * @param string $sortorder Sort Order
  317. * @param string $sortfield Sort field
  318. * @param int $limit limit
  319. * @param int $offset Offset
  320. * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
  321. * @param string $filtermode Filter mode (AND or OR)
  322. * @return array|int int <0 if KO, array of pages if OK
  323. */
  324. public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
  325. {
  326. global $conf;
  327. dol_syslog(__METHOD__, LOG_DEBUG);
  328. $records = array();
  329. $sql = 'SELECT ';
  330. $sql .= $this->getFieldList('t');
  331. $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
  332. if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
  333. $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
  334. } else {
  335. $sql .= ' WHERE 1 = 1';
  336. }
  337. // Manage filter
  338. $sqlwhere = array();
  339. if (count($filter) > 0) {
  340. foreach ($filter as $key => $value) {
  341. if ($key == 't.rowid') {
  342. $sqlwhere[] = $key." = ".((int) $value);
  343. } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
  344. $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
  345. } elseif ($key == 'customsql') {
  346. $sqlwhere[] = $value;
  347. } elseif (strpos($value, '%') === false) {
  348. $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')';
  349. } else {
  350. $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
  351. }
  352. }
  353. }
  354. if (count($sqlwhere) > 0) {
  355. $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
  356. }
  357. if (!empty($sortfield)) {
  358. $sql .= $this->db->order($sortfield, $sortorder);
  359. }
  360. if (!empty($limit)) {
  361. $sql .= $this->db->plimit($limit, $offset);
  362. }
  363. $resql = $this->db->query($sql);
  364. if ($resql) {
  365. $num = $this->db->num_rows($resql);
  366. $i = 0;
  367. while ($i < ($limit ? min($limit, $num) : $num)) {
  368. $obj = $this->db->fetch_object($resql);
  369. $record = new self($this->db);
  370. $record->setVarsFromFetchObj($obj);
  371. $records[$record->id] = $record;
  372. $i++;
  373. }
  374. $this->db->free($resql);
  375. return $records;
  376. } else {
  377. $this->errors[] = 'Error '.$this->db->lasterror();
  378. dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
  379. return -1;
  380. }
  381. }
  382. /**
  383. * Update object into database
  384. *
  385. * @param User $user User that modifies
  386. * @param bool $notrigger false=launch triggers after, true=disable triggers
  387. * @return int <0 if KO, >0 if OK
  388. */
  389. public function update(User $user, $notrigger = false)
  390. {
  391. return $this->updateCommon($user, $notrigger);
  392. }
  393. /**
  394. * Delete object in database
  395. *
  396. * @param User $user User that deletes
  397. * @param bool $notrigger false=launch triggers after, true=disable triggers
  398. * @return int <0 if KO, >0 if OK
  399. */
  400. public function delete(User $user, $notrigger = false)
  401. {
  402. $error = 0;
  403. $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement WHERE fk_knowledgemanagement = ".((int) $this->id);
  404. dol_syslog(get_class($this)."::delete", LOG_DEBUG);
  405. $resql = $this->db->query($sql);
  406. if (!$resql) {
  407. $error++;
  408. $this->error .= $this->db->lasterror();
  409. $errorflag = -1;
  410. }
  411. // Delete all child tables
  412. if (!$error) {
  413. $elements = array('categorie_knowledgemanagement');
  414. foreach ($elements as $table) {
  415. if (!$error) {
  416. $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table;
  417. $sql .= " WHERE fk_knowledgemanagement = ".(int) $this->id;
  418. $result = $this->db->query($sql);
  419. if (!$result) {
  420. $error++;
  421. $this->errors[] = $this->db->lasterror();
  422. }
  423. }
  424. }
  425. }
  426. return $this->deleteCommon($user, $notrigger);
  427. //return $this->deleteCommon($user, $notrigger, 1);
  428. }
  429. /**
  430. * Delete a line of object in database
  431. *
  432. * @param User $user User that delete
  433. * @param int $idline Id of line to delete
  434. * @param bool $notrigger false=launch triggers after, true=disable triggers
  435. * @return int >0 if OK, <0 if KO
  436. */
  437. public function deleteLine(User $user, $idline, $notrigger = false)
  438. {
  439. if ($this->status < 0) {
  440. $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
  441. return -2;
  442. }
  443. return $this->deleteLineCommon($user, $idline, $notrigger);
  444. }
  445. /**
  446. * Validate object
  447. *
  448. * @param User $user User making status change
  449. * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
  450. * @return int <=0 if OK, 0=Nothing done, >0 if KO
  451. */
  452. public function validate($user, $notrigger = 0)
  453. {
  454. global $conf, $langs;
  455. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  456. $error = 0;
  457. // Protection
  458. if ($this->status == self::STATUS_VALIDATED) {
  459. dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
  460. return 0;
  461. }
  462. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgerecord->write))
  463. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgerecord->knowledgerecord_advance->validate))))
  464. {
  465. $this->error='NotEnoughPermissions';
  466. dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
  467. return -1;
  468. }*/
  469. $now = dol_now();
  470. $this->db->begin();
  471. // Define new ref
  472. if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
  473. $num = $this->getNextNumRef();
  474. } else {
  475. $num = $this->ref;
  476. }
  477. $this->newref = $num;
  478. if (!empty($num)) {
  479. // Validate
  480. $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
  481. $sql .= " SET ref = '".$this->db->escape($num)."',";
  482. $sql .= " status = ".self::STATUS_VALIDATED;
  483. if (!empty($this->fields['date_validation'])) {
  484. $sql .= ", date_validation = '".$this->db->idate($now)."'";
  485. }
  486. if (!empty($this->fields['fk_user_valid'])) {
  487. $sql .= ", fk_user_valid = ".((int) $user->id);
  488. }
  489. $sql .= " WHERE rowid = ".((int) $this->id);
  490. dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
  491. $resql = $this->db->query($sql);
  492. if (!$resql) {
  493. dol_print_error($this->db);
  494. $this->error = $this->db->lasterror();
  495. $error++;
  496. }
  497. if (!$error && !$notrigger) {
  498. // Call trigger
  499. $result = $this->call_trigger('KNOWLEDGERECORD_VALIDATE', $user);
  500. if ($result < 0) {
  501. $error++;
  502. }
  503. // End call triggers
  504. }
  505. }
  506. if (!$error) {
  507. $this->oldref = $this->ref;
  508. // Rename directory if dir was a temporary ref
  509. if (preg_match('/^[\(]?PROV/i', $this->ref)) {
  510. // Now we rename also files into index
  511. $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'knowledgerecord/".$this->db->escape($this->newref)."'";
  512. $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'knowledgerecord/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
  513. $resql = $this->db->query($sql);
  514. if (!$resql) {
  515. $error++; $this->error = $this->db->lasterror();
  516. }
  517. // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
  518. $oldref = dol_sanitizeFileName($this->ref);
  519. $newref = dol_sanitizeFileName($num);
  520. $dirsource = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.$oldref;
  521. $dirdest = $conf->knowledgemanagement->dir_output.'/knowledgerecord/'.$newref;
  522. if (!$error && file_exists($dirsource)) {
  523. dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
  524. if (@rename($dirsource, $dirdest)) {
  525. dol_syslog("Rename ok");
  526. // Rename docs starting with $oldref with $newref
  527. $listoffiles = dol_dir_list($conf->knowledgemanagement->dir_output.'/knowledgerecord/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
  528. foreach ($listoffiles as $fileentry) {
  529. $dirsource = $fileentry['name'];
  530. $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
  531. $dirsource = $fileentry['path'].'/'.$dirsource;
  532. $dirdest = $fileentry['path'].'/'.$dirdest;
  533. @rename($dirsource, $dirdest);
  534. }
  535. }
  536. }
  537. }
  538. }
  539. // Set new ref and current status
  540. if (!$error) {
  541. $this->ref = $num;
  542. $this->status = self::STATUS_VALIDATED;
  543. }
  544. if (!$error) {
  545. $this->db->commit();
  546. return 1;
  547. } else {
  548. $this->db->rollback();
  549. return -1;
  550. }
  551. }
  552. /**
  553. * Set draft status
  554. *
  555. * @param User $user Object user that modify
  556. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  557. * @return int <0 if KO, >0 if OK
  558. */
  559. public function setDraft($user, $notrigger = 0)
  560. {
  561. // Protection
  562. if ($this->status <= self::STATUS_DRAFT) {
  563. return 0;
  564. }
  565. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->write))
  566. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgemanagement_advance->validate))))
  567. {
  568. $this->error='Permission denied';
  569. return -1;
  570. }*/
  571. return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'KNOWLEDGERECORD_UNVALIDATE');
  572. }
  573. /**
  574. * Set cancel status
  575. *
  576. * @param User $user Object user that modify
  577. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  578. * @return int <0 if KO, 0=Nothing done, >0 if OK
  579. */
  580. public function cancel($user, $notrigger = 0)
  581. {
  582. // Protection
  583. if ($this->status != self::STATUS_VALIDATED) {
  584. return 0;
  585. }
  586. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->write))
  587. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgemanagement_advance->validate))))
  588. {
  589. $this->error='Permission denied';
  590. return -1;
  591. }*/
  592. return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'KNOWLEDGERECORD_CANCEL');
  593. }
  594. /**
  595. * Set back to validated status
  596. *
  597. * @param User $user Object user that modify
  598. * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
  599. * @return int <0 if KO, 0=Nothing done, >0 if OK
  600. */
  601. public function reopen($user, $notrigger = 0)
  602. {
  603. // Protection
  604. if ($this->status != self::STATUS_CANCELED) {
  605. return 0;
  606. }
  607. /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->write))
  608. || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgemanagement_advance->validate))))
  609. {
  610. $this->error='Permission denied';
  611. return -1;
  612. }*/
  613. return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'KNOWLEDGERECORD_REOPEN');
  614. }
  615. /**
  616. * Return a link to the object card (with optionaly the picto)
  617. *
  618. * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
  619. * @param string $option On what the link point to ('nolink', ...)
  620. * @param int $notooltip 1=Disable tooltip
  621. * @param string $morecss Add more css on link
  622. * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
  623. * @return string String with URL
  624. */
  625. public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
  626. {
  627. global $conf, $langs, $hookmanager;
  628. if (!empty($conf->dol_no_mouse_hover)) {
  629. $notooltip = 1; // Force disable tooltips
  630. }
  631. $result = '';
  632. $label = img_picto('', $this->picto).' <u>'.$langs->trans("KnowledgeRecord").'</u>';
  633. if (isset($this->status)) {
  634. $label .= ' '.$this->getLibStatut(5);
  635. }
  636. $label .= '<br>';
  637. $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
  638. $url = dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?id='.$this->id;
  639. if ($option != 'nolink') {
  640. // Add param to save lastsearch_values or not
  641. $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
  642. if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
  643. $add_save_lastsearch_values = 1;
  644. }
  645. if ($add_save_lastsearch_values) {
  646. $url .= '&save_lastsearch_values=1';
  647. }
  648. }
  649. $linkclose = '';
  650. if (empty($notooltip)) {
  651. if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  652. $label = $langs->trans("ShowKnowledgeRecord");
  653. $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
  654. }
  655. $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
  656. $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
  657. } else {
  658. $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
  659. }
  660. if ($option == 'nolink') {
  661. $linkstart = '<span';
  662. } else {
  663. $linkstart = '<a href="'.$url.'"';
  664. }
  665. $linkstart .= $linkclose.'>';
  666. if ($option == 'nolink') {
  667. $linkend = '</span>';
  668. } else {
  669. $linkend = '</a>';
  670. }
  671. $result .= $linkstart;
  672. if (empty($this->showphoto_on_popup)) {
  673. if ($withpicto) {
  674. $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
  675. }
  676. } else {
  677. if ($withpicto) {
  678. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  679. list($class, $module) = explode('@', $this->picto);
  680. $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
  681. $filearray = dol_dir_list($upload_dir, "files");
  682. $filename = $filearray[0]['name'];
  683. if (!empty($filename)) {
  684. $pospoint = strpos($filearray[0]['name'], '.');
  685. $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
  686. if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
  687. $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
  688. } else {
  689. $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
  690. }
  691. $result .= '</div>';
  692. } else {
  693. $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
  694. }
  695. }
  696. }
  697. if ($withpicto != 2) {
  698. $result .= $this->ref;
  699. }
  700. $result .= $linkend;
  701. //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
  702. global $action, $hookmanager;
  703. $hookmanager->initHooks(array('knowledgerecorddao'));
  704. $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
  705. $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
  706. if ($reshook > 0) {
  707. $result = $hookmanager->resPrint;
  708. } else {
  709. $result .= $hookmanager->resPrint;
  710. }
  711. return $result;
  712. }
  713. /**
  714. * Return the label of the status
  715. *
  716. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
  717. * @return string Label of status
  718. */
  719. public function getLibStatut($mode = 0)
  720. {
  721. return $this->LibStatut($this->status, $mode);
  722. }
  723. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  724. /**
  725. * Return the status
  726. *
  727. * @param int $status Id status
  728. * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
  729. * @return string Label of status
  730. */
  731. public function LibStatut($status, $mode = 0)
  732. {
  733. // phpcs:enable
  734. if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
  735. global $langs;
  736. //$langs->load("knowledgemanagement");
  737. $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  738. $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
  739. $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Obsolete');
  740. $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
  741. $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
  742. $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Obsolete');
  743. }
  744. $statusType = 'status'.$status;
  745. if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
  746. if ($status == self::STATUS_CANCELED) {
  747. $statusType = 'status6';
  748. }
  749. return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
  750. }
  751. /**
  752. * Load the info information in the object
  753. *
  754. * @param int $id Id of object
  755. * @return void
  756. */
  757. public function info($id)
  758. {
  759. $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
  760. $sql .= ' fk_user_creat, fk_user_modif';
  761. $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
  762. $sql .= ' WHERE t.rowid = '.((int) $id);
  763. $result = $this->db->query($sql);
  764. if ($result) {
  765. if ($this->db->num_rows($result)) {
  766. $obj = $this->db->fetch_object($result);
  767. $this->id = $obj->rowid;
  768. $this->user_creation_id = $obj->fk_user_creat;
  769. $this->user_modification_id = $obj->fk_user_modif;
  770. $this->date_creation = $this->db->jdate($obj->datec);
  771. $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
  772. }
  773. $this->db->free($result);
  774. } else {
  775. dol_print_error($this->db);
  776. }
  777. }
  778. /**
  779. * Initialise object with example values
  780. * Id must be 0 if object instance is a specimen
  781. *
  782. * @return void
  783. */
  784. public function initAsSpecimen()
  785. {
  786. $this->question = "ABCD";
  787. $this->initAsSpecimenCommon();
  788. }
  789. /**
  790. * Create an array of lines
  791. *
  792. * @return array|int array of lines if OK, <0 if KO
  793. */
  794. public function getLinesArray()
  795. {
  796. $this->lines = array();
  797. $objectline = new KnowledgeRecordLine($this->db);
  798. $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_knowledgerecord = '.((int) $this->id)));
  799. if (is_numeric($result)) {
  800. $this->error = $objectline->error;
  801. $this->errors = $objectline->errors;
  802. return $result;
  803. } else {
  804. $this->lines = $result;
  805. return $this->lines;
  806. }
  807. }
  808. /**
  809. * Returns the reference to the following non used object depending on the active numbering module.
  810. *
  811. * @return string Object free reference
  812. */
  813. public function getNextNumRef()
  814. {
  815. global $langs, $conf;
  816. $langs->load("knowledgemanagement");
  817. if (empty($conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON)) {
  818. $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON = 'mod_knowledgerecord_standard';
  819. }
  820. if (!empty($conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON)) {
  821. $mybool = false;
  822. $file = $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON.".php";
  823. $classname = $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON;
  824. // Include file with class
  825. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  826. foreach ($dirmodels as $reldir) {
  827. $dir = dol_buildpath($reldir."core/modules/knowledgemanagement/");
  828. // Load file with numbering class (if found)
  829. $mybool |= @include_once $dir.$file;
  830. }
  831. if ($mybool === false) {
  832. dol_print_error('', "Failed to include file ".$file);
  833. return '';
  834. }
  835. if (class_exists($classname)) {
  836. $obj = new $classname();
  837. $numref = $obj->getNextValue($this);
  838. if ($numref != '' && $numref != '-1') {
  839. return $numref;
  840. } else {
  841. $this->error = $obj->error;
  842. //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
  843. return "";
  844. }
  845. } else {
  846. print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
  847. return "";
  848. }
  849. } else {
  850. print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
  851. return "";
  852. }
  853. }
  854. /**
  855. * Create a document onto disk according to template module.
  856. *
  857. * @param string $modele Force template to use ('' to not force)
  858. * @param Translate $outputlangs objet lang a utiliser pour traduction
  859. * @param int $hidedetails Hide details of lines
  860. * @param int $hidedesc Hide description
  861. * @param int $hideref Hide ref
  862. * @param null|array $moreparams Array to provide more information
  863. * @return int 0 if KO, 1 if OK
  864. */
  865. public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
  866. {
  867. global $conf, $langs;
  868. $result = 0;
  869. $includedocgeneration = 0;
  870. $langs->load("knowledgemanagement");
  871. if (!dol_strlen($modele)) {
  872. $modele = 'standard_knowledgerecord';
  873. if (!empty($this->model_pdf)) {
  874. $modele = $this->model_pdf;
  875. } elseif (!empty($conf->global->KNOWLEDGERECORD_ADDON_PDF)) {
  876. $modele = $conf->global->KNOWLEDGERECORD_ADDON_PDF;
  877. }
  878. }
  879. $modelpath = "core/modules/knowledgemanagement/doc/";
  880. if ($includedocgeneration && !empty($modele)) {
  881. $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
  882. }
  883. return $result;
  884. }
  885. /**
  886. * Action executed by scheduler
  887. * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
  888. * Use public function doScheduledJob($param1, $param2, ...) to get parameters
  889. *
  890. * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
  891. */
  892. public function doScheduledJob()
  893. {
  894. global $conf, $langs;
  895. //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
  896. $error = 0;
  897. $this->output = '';
  898. $this->error = '';
  899. dol_syslog(__METHOD__, LOG_DEBUG);
  900. $now = dol_now();
  901. $this->db->begin();
  902. // ...
  903. $this->db->commit();
  904. return $error;
  905. }
  906. /**
  907. * Sets object to supplied categories.
  908. *
  909. * Deletes object from existing categories not supplied.
  910. * Adds it to non existing supplied categories.
  911. * Existing categories are left untouch.
  912. *
  913. * @param int[]|int $categories Category or categories IDs
  914. * @return int <0 if KO, >0 if OK
  915. */
  916. public function setCategories($categories)
  917. {
  918. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  919. return parent::setCategoriesCommon($categories, Categorie::TYPE_KNOWLEDGEMANAGEMENT);
  920. }
  921. }
  922. require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
  923. /**
  924. * Class KnowledgeRecordLine. You can also remove this and generate a CRUD class for lines objects.
  925. */
  926. class KnowledgeRecordLine extends CommonObjectLine
  927. {
  928. // To complete with content of an object KnowledgeRecordLine
  929. // We should have a field rowid, fk_knowledgerecord and position
  930. /**
  931. * @var int Does object support extrafields ? 0=No, 1=Yes
  932. */
  933. public $isextrafieldmanaged = 0;
  934. /**
  935. * Constructor
  936. *
  937. * @param DoliDb $db Database handler
  938. */
  939. public function __construct(DoliDB $db)
  940. {
  941. $this->db = $db;
  942. }
  943. }