diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index ecf95c5096d..60855c42d58 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -43,23 +43,23 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
class Categorie extends CommonObject
{
// Categories types
- const TYPE_PRODUCT = 0; // TODO Replace with value 'product'
- const TYPE_SUPPLIER = 1; // TODO Replace this value with 'supplier'
- const TYPE_CUSTOMER = 2; // TODO Replace this value with 'customer'
- const TYPE_MEMBER = 3; // TODO Replace this value with 'member'
- const TYPE_CONTACT = 4; // TODO Replace this value with 'contact'
- const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user'
-
- const TYPE_ACCOUNT = 5; // TODO Replace this value with 'bank_account'
- const TYPE_PROJECT = 6; // TODO Replace this value with 'project'
+ const TYPE_PRODUCT = 'product';
+ const TYPE_SUPPLIER = 'supplier';
+ const TYPE_CUSTOMER = 'customer';
+ const TYPE_MEMBER = 'member';
+ const TYPE_CONTACT = 'contact';
+ const TYPE_USER = 'user';
+ const TYPE_PROJECT = 'project';
+ const TYPE_ACCOUNT = 'bank_account';
const TYPE_BANK_LINE = 'bank_line';
+
public $picto = 'category';
/**
* @var array ID mapping from type string
*
- * @note This array should be remove in future, once previous constants are moved to the string value.
+ * @note This array should be remove in future, once previous constants are moved to the string value. Deprecated
*/
private $MAP_ID = array(
'product' => 0,
@@ -67,10 +67,21 @@ class Categorie extends CommonObject
'customer' => 2,
'member' => 3,
'contact' => 4,
- 'user' => 4,
'account' => 5,
'project' => 6,
+ 'user' => 7,
);
+ public static $MAP_ID_TO_CODE = array(
+ 0 => 'product',
+ 1 => 'supplier',
+ 2 => 'customer',
+ 3 => 'member',
+ 4 => 'contact',
+ 5 => 'account',
+ 6 => 'project',
+ 7 => 'user',
+ );
+
/**
* @var array Foreign keys mapping from type string
*
@@ -82,9 +93,9 @@ class Categorie extends CommonObject
'supplier' => 'soc',
'member' => 'member',
'contact' => 'socpeople',
- 'user' => 'user',
- 'account' => 'account',
- 'project' => 'project',
+ 'user' => 'user',
+ 'account' => 'account',
+ 'project' => 'project',
);
/**
* @var array Category tables mapping from type string
@@ -97,9 +108,9 @@ class Categorie extends CommonObject
'supplier' => 'fournisseur',
'member' => 'member',
'contact' => 'contact',
- 'user' => 'user',
- 'account' => 'account',
- 'project' => 'project',
+ 'user' => 'user',
+ 'account' => 'account',
+ 'project' => 'project',
);
/**
* @var array Object class mapping from type string
@@ -113,8 +124,8 @@ class Categorie extends CommonObject
'member' => 'Adherent',
'contact' => 'Contact',
'user' => 'User',
- 'account' => 'Account',
- 'project' => 'Project',
+ 'account' => 'Account',
+ 'project' => 'Project',
);
/**
* @var array Object table mapping from type string
@@ -128,8 +139,8 @@ class Categorie extends CommonObject
'member' => 'adherent',
'contact' => 'socpeople',
'user' => 'user',
- 'account' => 'bank_account',
- 'project' => 'projet',
+ 'account' => 'bank_account',
+ 'project' => 'projet',
);
public $element='category';
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index ea4d60e9b5b..c751fad67a7 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -39,6 +39,8 @@ $id=GETPOST('id','int');
$type=(GETPOST('type','aZ09') ? GETPOST('type','aZ09') : Categorie::TYPE_PRODUCT);
$catname=GETPOST('catname','alpha');
+if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
+
/*
* View
@@ -53,8 +55,8 @@ elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCat
elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; }
elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; }
elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='account'; }
-elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; }
elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; }
+elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; }
else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; }
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index e99e081e015..e6047ed2149 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -42,6 +42,8 @@ $type=GETPOST('type');
$action=GETPOST('action','aZ09');
$confirm=GETPOST('confirm');
+if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
+
if ($id == "")
{
dol_print_error('','Missing parameter id');
@@ -100,15 +102,16 @@ if ($object->id)
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
- else $title=$langs->trans("Category");
+ elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort");
+ else $title=$langs->trans("Category");
$head = categories_prepare_head($object,$type);
dol_fiche_head($head, 'photos', $title, -1, 'category');
-
+
$linkback = ''.$langs->trans("BackToList").'';
-
+
$object->ref = $object->label;
$morehtmlref='