mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
New: Add trigger CATEGORY_LINK and CATEGORY_UNLINK.
This commit is contained in:
parent
0621233b9a
commit
8e5537f1ce
|
|
@ -47,7 +47,6 @@ For users:
|
|||
- New: [ task #918 ] Stock replenishment
|
||||
- Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count
|
||||
|
||||
|
||||
For translators:
|
||||
- Qual: Normalized sort order of all languages files with english reference files.
|
||||
- New: Add language code files for South Africa.
|
||||
|
|
@ -72,6 +71,7 @@ For developers:
|
|||
separated by a coma, of other POST parameters, Dolibarr will automatically save this parameters
|
||||
into user cookies.
|
||||
- New: Add hook addHomeSetup.
|
||||
- New: Add trigger CATEGORY_LINK and CATEGORY_UNLINK.
|
||||
|
||||
WARNING: Following change may create regression for some external modules, but was necessary to make
|
||||
Dolibarr better:
|
||||
|
|
|
|||
|
|
@ -360,6 +360,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
|
|||
}
|
||||
|
||||
// Rajoute l'utilisateur dans les divers abonnements (mailman, spip, etc...)
|
||||
// TODO Move this into update trigger MEMBER_MODIFY
|
||||
if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))
|
||||
{
|
||||
if ($object->oldcopy->email != $object->email) // If email has changed we delete mailman subscription for old email
|
||||
|
|
@ -1411,7 +1412,7 @@ else
|
|||
|
||||
// EMail
|
||||
print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.dol_print_email($object->email,0,$object->fk_soc,1).'</td></tr>';
|
||||
|
||||
|
||||
// Password
|
||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -390,16 +390,16 @@ class Categorie
|
|||
function add_type($obj,$type)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$error=0;
|
||||
|
||||
if ($this->id == -1) return -2;
|
||||
|
||||
|
||||
if ($type == 'company') $type='societe';
|
||||
if ($type == 'fournisseur') $type='societe';
|
||||
|
||||
|
||||
$column_name=$type;
|
||||
if ($type=='contact') {
|
||||
$column_name='socpeople';
|
||||
}
|
||||
if ($type=='contact') $column_name='socpeople';
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$column_name.")";
|
||||
$sql .= " VALUES (".$this->id.", ".$obj->id.")";
|
||||
|
|
@ -407,10 +407,11 @@ class Categorie
|
|||
dol_syslog(get_class($this).'::add_type sql='.$sql);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
|
||||
if (!empty($conf->global->CATEGORIE_RECURSIV_ADD))
|
||||
{
|
||||
$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie';
|
||||
$sql.= " WHERE rowid = '".$this->id."'";
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::add_type sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
|
|
@ -418,7 +419,7 @@ class Categorie
|
|||
if ($this->db->num_rows($resql) > 0)
|
||||
{
|
||||
$objparent = $this->db->fetch_object($resql);
|
||||
|
||||
|
||||
if (!empty($objparent->fk_parent)) {
|
||||
$cat = new Categorie($this->db);
|
||||
$cat->id=$objparent->fk_parent;
|
||||
|
|
@ -428,12 +429,23 @@ class Categorie
|
|||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
// Save object we want to link category to into category instance to provide information to trigger
|
||||
$this->linkto=$object;
|
||||
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('CATEGORY_LINK',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; $this->error=join(',',$this->errors); }
|
||||
// Fin appel triggers
|
||||
|
||||
if (! $error) return 1;
|
||||
else return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -444,7 +456,7 @@ class Categorie
|
|||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
$this->error=$this->db->lasterror();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -459,10 +471,11 @@ class Categorie
|
|||
*/
|
||||
function del_type($obj,$type)
|
||||
{
|
||||
$error=0;
|
||||
|
||||
if ($type == 'company') $type='societe';
|
||||
if ($type == 'fournisseur') $type='societe';
|
||||
|
||||
|
||||
$column_name=$type;
|
||||
if ($type=='contact') $column_name='socpeople';
|
||||
|
||||
|
|
@ -473,11 +486,22 @@ class Categorie
|
|||
dol_syslog(get_class($this).'::del_type sql='.$sql);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
return 1;
|
||||
// Save object we want to unlink category off into category instance to provide information to trigger
|
||||
$this->unlinkoff=$obj;
|
||||
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('CATEGORY_UNLINK',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; $this->error=join(',',$this->errors); }
|
||||
// Fin appel triggers
|
||||
|
||||
if (! $error) return 1;
|
||||
else return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user