Skip to content

Commit

Permalink
Add X_SET_MULTILANGS triggers to make possible reacting on translatio…
Browse files Browse the repository at this point in the history
…n changes for products and categories
  • Loading branch information
ParisLiakos committed Nov 16, 2015
1 parent 298a671 commit 146aa78
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
13 changes: 12 additions & 1 deletion htdocs/categories/class/categorie.class.php
Expand Up @@ -1508,9 +1508,11 @@ function get_image_size($file)
/**
* 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;

Expand Down Expand Up @@ -1574,6 +1576,15 @@ function setMultiLangs()
}
}
}

// 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;
}

Expand Down
4 changes: 2 additions & 2 deletions htdocs/categories/traduction.php
Expand Up @@ -88,7 +88,7 @@
}

// sauvegarde en base
if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
Expand Down Expand Up @@ -121,7 +121,7 @@
}
}

if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
Expand Down
2 changes: 2 additions & 0 deletions htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
Expand Up @@ -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':
Expand Down Expand Up @@ -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':
Expand Down
15 changes: 13 additions & 2 deletions htdocs/product/class/product.class.php
Expand Up @@ -738,7 +738,7 @@ function update($id, $user, $notrigger=false, $action='update')
// 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;
Expand Down Expand Up @@ -968,9 +968,11 @@ function delete($id=0)
/**
* 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;

Expand Down Expand Up @@ -1049,6 +1051,15 @@ function setMultiLangs()
// 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;
}

Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/traduction.php
Expand Up @@ -87,7 +87,7 @@
}

// sauvegarde en base
if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
Expand Down Expand Up @@ -123,7 +123,7 @@
}
}

if ( $object->setMultiLangs() > 0 )
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
Expand Down

0 comments on commit 146aa78

Please sign in to comment.