Add X_SET_MULTILANGS triggers to make possible reacting on translation changes for products and categories

This commit is contained in:
Paris Liakos 2015-11-16 20:27:51 +02:00
parent 298a671342
commit 146aa7815b
5 changed files with 31 additions and 7 deletions

View File

@ -1508,9 +1508,11 @@ class Categorie extends CommonObject
/**
* Update ou cree les traductions des infos produits
*
* @param User $user Object user
*
* @return int <0 if KO, >0 if OK
*/
function setMultiLangs()
function setMultiLangs($user)
{
global $langs;
@ -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;
}

View File

@ -88,7 +88,7 @@ $cancel != $langs->trans("Cancel") &&
}
// sauvegarde en base
if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
@ -121,7 +121,7 @@ $cancel != $langs->trans("Cancel") &&
}
}
if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}

View File

@ -100,6 +100,7 @@ class InterfaceDemo extends DolibarrTriggers
case 'PRODUCT_MODIFY':
case 'PRODUCT_DELETE':
case 'PRODUCT_PRICE_MODIFY':
case 'PRODUCT_SET_MULTILANGS':
//Stock mouvement
case 'STOCK_MOVEMENT':
@ -234,6 +235,7 @@ class InterfaceDemo extends DolibarrTriggers
case 'CATEGORY_CREATE':
case 'CATEGORY_MODIFY':
case 'CATEGORY_DELETE':
case 'CATEGORY_SET_MULTILANGS':
// Projects
case 'PROJECT_CREATE':

View File

@ -738,7 +738,7 @@ class Product extends CommonObject
// 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;
return -2;
@ -968,9 +968,11 @@ class Product extends CommonObject
/**
* Update or add a translation for a product
*
* @param User $user Object user making update
*
* @return int <0 if KO, >0 if OK
*/
function setMultiLangs()
function setMultiLangs($user)
{
global $langs;
@ -1049,6 +1051,15 @@ class Product extends CommonObject
// 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;
}

View File

@ -87,7 +87,7 @@ $cancel != $langs->trans("Cancel") &&
}
// sauvegarde en base
if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
@ -123,7 +123,7 @@ $cancel != $langs->trans("Cancel") &&
}
}
if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}