@@ -5447,25 +5447,26 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided
54475447 /**
54485448 * Sets object to supplied categories.
54495449 *
5450- * Deletes object from existing categories not supplied .
5451- * Adds it to non existing supplied categories.
5452- * Existing categories are left untouch.
5450+ * Assign the object to all categories not yet assigned .
5451+ * Unasign object from existing categories not supplied in $ categories (if remove_existing==true) .
5452+ * If remove_existing is false, existing categories are left untouch.
54535453 *
5454- * @param int[]|int $categories Category ID or array of Categories IDs
5455- * @param string $type_categ Category type ('customer' or 'supplier')
5456- * @return int Return integer <0 if KO, >0 if OK
5454+ * @param int[]|int $categories Category ID or array of Categories IDs
5455+ * @param string $type_categ Category type ('customer' or 'supplier')
5456+ * @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them
5457+ * @return int Return integer <0 if KO, >0 if OK
54575458 */
5458- public function setCategories ($ categories , $ type_categ )
5459+ public function setCategories ($ categories , $ type_categ, $ remove_existing = true )
54595460 {
54605461 require_once DOL_DOCUMENT_ROOT .'/categories/class/categorie.class.php ' ;
54615462
54625463 // Decode type
54635464 if (!in_array ($ type_categ , array (Categorie::TYPE_CUSTOMER , Categorie::TYPE_SUPPLIER ))) {
5464- dol_syslog (__METHOD__ .': Type ' .$ type_categ .'is an unknown company category type. Done nothing . ' , LOG_ERR );
5465+ dol_syslog (__METHOD__ .': Type ' .$ type_categ .'is an unknown company category type. Nothing done . ' , LOG_ERR );
54655466 return -1 ;
54665467 }
54675468
5468- return parent ::setCategoriesCommon ($ categories , $ type_categ );
5469+ return parent ::setCategoriesCommon ($ categories , $ type_categ, $ remove_existing );
54695470 }
54705471
54715472 /**
0 commit comments