Skip to content
Snippets Groups Projects
Commit 146aa781 authored by Paris Liakos's avatar Paris Liakos
Browse files

Add X_SET_MULTILANGS triggers to make possible reacting on translation changes...

Add X_SET_MULTILANGS triggers to make possible reacting on translation changes for products and categories
parent 298a6713
Branches
Tags
No related merge requests found
...@@ -1508,9 +1508,11 @@ class Categorie extends CommonObject ...@@ -1508,9 +1508,11 @@ class Categorie extends CommonObject
/** /**
* Update ou cree les traductions des infos produits * Update ou cree les traductions des infos produits
* *
* @param User $user Object user
*
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setMultiLangs() function setMultiLangs($user)
{ {
global $langs; global $langs;
...@@ -1574,6 +1576,15 @@ class Categorie extends CommonObject ...@@ -1574,6 +1576,15 @@ class Categorie extends CommonObject
} }
} }
} }
// Call trigger
$result = $this->call_trigger('CATEGORY_SET_MULTILANGS',$user);
if ($result < 0) {
$this->error = $this->db->lasterror();
return -1;
}
// End call triggers
return 1; return 1;
} }
......
...@@ -88,7 +88,7 @@ $cancel != $langs->trans("Cancel") && ...@@ -88,7 +88,7 @@ $cancel != $langs->trans("Cancel") &&
} }
// sauvegarde en base // sauvegarde en base
if ( $object->setMultiLangs() > 0 ) if ( $object->setMultiLangs($user) > 0 )
{ {
$action = ''; $action = '';
} }
...@@ -121,7 +121,7 @@ $cancel != $langs->trans("Cancel") && ...@@ -121,7 +121,7 @@ $cancel != $langs->trans("Cancel") &&
} }
} }
if ( $object->setMultiLangs() > 0 ) if ( $object->setMultiLangs($user) > 0 )
{ {
$action = ''; $action = '';
} }
......
...@@ -100,6 +100,7 @@ class InterfaceDemo extends DolibarrTriggers ...@@ -100,6 +100,7 @@ class InterfaceDemo extends DolibarrTriggers
case 'PRODUCT_MODIFY': case 'PRODUCT_MODIFY':
case 'PRODUCT_DELETE': case 'PRODUCT_DELETE':
case 'PRODUCT_PRICE_MODIFY': case 'PRODUCT_PRICE_MODIFY':
case 'PRODUCT_SET_MULTILANGS':
//Stock mouvement //Stock mouvement
case 'STOCK_MOVEMENT': case 'STOCK_MOVEMENT':
...@@ -234,6 +235,7 @@ class InterfaceDemo extends DolibarrTriggers ...@@ -234,6 +235,7 @@ class InterfaceDemo extends DolibarrTriggers
case 'CATEGORY_CREATE': case 'CATEGORY_CREATE':
case 'CATEGORY_MODIFY': case 'CATEGORY_MODIFY':
case 'CATEGORY_DELETE': case 'CATEGORY_DELETE':
case 'CATEGORY_SET_MULTILANGS':
// Projects // Projects
case 'PROJECT_CREATE': case 'PROJECT_CREATE':
......
...@@ -738,7 +738,7 @@ class Product extends CommonObject ...@@ -738,7 +738,7 @@ class Product extends CommonObject
// Multilangs // Multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) if (! empty($conf->global->MAIN_MULTILANGS))
{ {
if ( $this->setMultiLangs() < 0) if ( $this->setMultiLangs($user) < 0)
{ {
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
return -2; return -2;
...@@ -968,9 +968,11 @@ class Product extends CommonObject ...@@ -968,9 +968,11 @@ class Product extends CommonObject
/** /**
* Update or add a translation for a product * Update or add a translation for a product
* *
* @param User $user Object user making update
*
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setMultiLangs() function setMultiLangs($user)
{ {
global $langs; global $langs;
...@@ -1049,6 +1051,15 @@ class Product extends CommonObject ...@@ -1049,6 +1051,15 @@ class Product extends CommonObject
// language is not current language and we didn't provide a multilang description for this language // language is not current language and we didn't provide a multilang description for this language
} }
} }
// Call trigger
$result = $this->call_trigger('PRODUCT_SET_MULTILANGS',$user);
if ($result < 0) {
$this->error = $this->db->lasterror();
return -1;
}
// End call triggers
return 1; return 1;
} }
......
...@@ -87,7 +87,7 @@ $cancel != $langs->trans("Cancel") && ...@@ -87,7 +87,7 @@ $cancel != $langs->trans("Cancel") &&
} }
// sauvegarde en base // sauvegarde en base
if ( $object->setMultiLangs() > 0 ) if ( $object->setMultiLangs($user) > 0 )
{ {
$action = ''; $action = '';
} }
...@@ -123,7 +123,7 @@ $cancel != $langs->trans("Cancel") && ...@@ -123,7 +123,7 @@ $cancel != $langs->trans("Cancel") &&
} }
} }
if ( $object->setMultiLangs() > 0 ) if ( $object->setMultiLangs($user) > 0 )
{ {
$action = ''; $action = '';
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment