Skip to content

Commit 8cd3abb

Browse files
committed
Can add a category without removing the others
1 parent bbd0172 commit 8cd3abb

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

htdocs/contact/class/contact.class.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,17 +1827,18 @@ public function setstatus($status)
18271827
/**
18281828
* Sets object to supplied categories.
18291829
*
1830-
* Deletes object from existing categories not supplied.
1831-
* Adds it to non existing supplied categories.
1832-
* Existing categories are left untouch.
1830+
* Assign the object to all categories not yet assigned.
1831+
* Unasign object from existing categories not supplied in $categories (if remove_existing==true).
1832+
* If remove_existing is false, existing categories are left untouch.
18331833
*
1834-
* @param int[]|int $categories Category or categories IDs
1835-
* @return int Return integer <0 if KO, >0 if OK
1834+
* @param int[]|int $categories Category or categories IDs
1835+
* @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them
1836+
* @return int Return integer <0 if KO, >0 if OK
18361837
*/
1837-
public function setCategories($categories)
1838+
public function setCategories($categories, $remove_existing = true)
18381839
{
18391840
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1840-
return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT);
1841+
return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT, $remove_existing);
18411842
}
18421843

18431844
/**

htdocs/core/class/commonobject.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11414,9 +11414,9 @@ public function getCategoriesCommon($type_categ)
1141411414
/**
1141511415
* Sets object to given categories.
1141611416
*
11417-
* Adds it to non existing supplied categories.
11418-
* Deletes object from existing categories not supplied (if remove_existing==true).
11419-
* Existing categories are left untouch.
11417+
* Assign the object to all categories not yet assigned.
11418+
* Unasign object from existing categories not supplied in $categories (if remove_existing==true).
11419+
* If remove_existing is false, existing categories are left untouch.
1142011420
*
1142111421
* @param int[]|int $categories Category ID or array of Categories IDs
1142211422
* @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) defined into const class Categorie type

htdocs/societe/class/societe.class.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)