From 26befa3b93f2f2fb51d03296f1e9ac7cbb64ce17 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 13 Apr 2020 15:38:50 +0200 Subject: [PATCH 1/6] New fields on usergroup object + card uses common tpl --- htdocs/user/class/usergroup.class.php | 10 ++ htdocs/user/group/card.php | 135 ++++++++++++-------------- 2 files changed, 70 insertions(+), 75 deletions(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 1f8040a83ea..9c48c321196 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -100,6 +100,16 @@ class UserGroup extends CommonObject public $oldcopy; // To contains a clone of this when we need to save old properties of object + public $fields = array( + 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), + 'nom'=>array('type'=>'varchar(180)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Group name'), + 'note' => array('type'=>'html', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1,), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>50, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>60, 'notnull'=>1,), + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>100), + ); + /** * Constructor de la classe diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 335b66ebdd2..f3ae62beed8 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -54,6 +54,7 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); $userid = GETPOST('user', 'int'); @@ -91,19 +92,20 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { + + $backurlforlist = DOL_URL_ROOT.'/user/group/list.php'; + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + } + if ($cancel) { - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - else - { - header("Location: ".DOL_URL_ROOT.'/user/group/list.php'); - exit; - } - $action = ''; + header("Location: ".$backtopage); + exit; } // Action remove group @@ -215,7 +217,7 @@ if (empty($reshook)) { $object->oldcopy = clone $object; - $object->name = trim(GETPOST("group", 'nohtml')); + $object->name = trim(GETPOST("nom", 'nohtml')); $object->nom = $object->name; // For backward compatibility $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'none'))); @@ -273,14 +275,11 @@ if ($action == 'create') print '
'; print ''; print ''; + print ''; dol_fiche_head('', '', '', 0, ''); - print ''; - - print ""; - print ''; - print ''; + print '
'.$langs->trans("Name").'
'; // Multicompany if (!empty($conf->multicompany->enabled) && is_object($mc)) @@ -297,27 +296,18 @@ if ($action == 'create') } } - print "".'\n"; + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; // Other attributes - $parameters = array('object' => $object); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - print "
'.$langs->trans("Description").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', '', '', 240, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); - $doleditor->Create(); - print "
\n"; + print "\n"; dol_fiche_end(); print '
'; - print ''; + print ''; print '   '; print ''; print '
'; @@ -359,6 +349,7 @@ else dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); print '
'; + print '
'; print '
'; print ''; @@ -384,19 +375,18 @@ else print "\n"; } - // Note - print ''; - print ''; - print "\n"; + // Common attributes + $keyforbreak = ''; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes - $parameters = array('colspan' => ' colspan="2"'); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - print "
'.$langs->trans("Description").''; - print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note)); - print '
\n"; - print '
'; + print ''; + print '
'; + print ''; + + print '
'; dol_fiche_end(); @@ -407,6 +397,10 @@ else print '
'; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($caneditperms) { print ''.$langs->trans("Modify").''; @@ -421,7 +415,7 @@ else // List users in group - print load_fiche_titre($langs->trans("ListOfUsersInGroup"), '', ''); + print load_fiche_titre($langs->trans("ListOfUsersInGroup"), '', 'user'); // On selectionne les users qui ne sont pas deja dans le groupe $exclude = array(); @@ -485,7 +479,7 @@ else print ''; print ''.$useringroup->lastname.''; print ''.$useringroup->firstname.''; - print ''.$useringroup->getLibStatut(3).''; + print ''.$useringroup->getLibStatut(5).''; print ''; if (!empty($user->admin)) { print ''; @@ -542,53 +536,44 @@ else if ($action == 'edit' && $caneditperms) { - print ''; + print ''; print ''; print ''; + print ''; + print ''; dol_fiche_head($head, 'group', $title, 0, 'group'); - print ''; - print ''; - print '\n"; + print '
'.$langs->trans("Name").''; - print "
'."\n"; - // Multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) - { - print "".''; - print "\n"; - } - else - { + // Multicompany + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) + { + print "".''; + print "\n"; + } + else + { print ''; } - } + } + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - print ''; - print ''; - print "\n"; // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - print "
'.$langs->trans("Entity").'".$mc->select_entities($object->entity); - print "
'.$langs->trans("Entity").'".$mc->select_entities($object->entity); + print "
'.$langs->trans("Description").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note, '', 240, 'dolibarr_notes', '', true, false, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); - $doleditor->Create(); - print '
\n"; + print ''; dol_fiche_end(); - print '
'; + print '
'; + print '   '; + print '
'; print ''; } From 2e004e93ea2161b53260d67abab8a8c7452140c4 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 13 Apr 2020 19:02:19 +0200 Subject: [PATCH 2/6] Commonobject : delete extrafields + syslog --- htdocs/core/class/commonobject.class.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4b94f87c65f..dcbb25775e7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7876,6 +7876,7 @@ abstract class CommonObject public function createCommon(User $user, $notrigger = false) { global $langs; + dol_syslog(get_class($this)."::createCommon create", LOG_DEBUG); $error = 0; @@ -8114,6 +8115,7 @@ abstract class CommonObject public function updateCommon(User $user, $notrigger = false) { global $conf, $langs; + dol_syslog(get_class($this)."::updateCommon update", LOG_DEBUG); $error = 0; @@ -8203,6 +8205,8 @@ abstract class CommonObject */ public function deleteCommon(User $user, $notrigger = false, $forcechilddeletion = 0) { + dol_syslog(get_class($this)."::deleteCommon delete", LOG_DEBUG); + $error = 0; $this->db->begin(); @@ -8260,17 +8264,10 @@ abstract class CommonObject } } - if (!$error && !empty($this->isextrafieldmanaged)) + if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; - $sql .= " WHERE fk_object=".$this->id; - - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errors[] = $this->db->lasterror(); - $error++; - } + $result = $this->deleteExtraFields(); + if ($result < 0) { $error++; } } if (!$error) From b8a0b4b6e4b86e6576fb7b3bbc4e3d2ffa4e9967 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 13 Apr 2020 19:03:48 +0200 Subject: [PATCH 3/6] New class UserGroup works with common functions now --- htdocs/user/class/usergroup.class.php | 212 ++++---------------------- htdocs/user/group/card.php | 14 +- 2 files changed, 37 insertions(+), 189 deletions(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 9c48c321196..269089c73f2 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -110,6 +110,21 @@ class UserGroup extends CommonObject 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>100), ); + /** + * @var int Field with ID of parent key if this field has a parent + */ + public $fk_element = 'fk_usergroup'; + + /** + * @var array List of child tables. To test if we can delete object. + */ + protected $childtables=array(); + + /** + * @var array List of child tables. To know object to delete on cascade. + */ + protected $childtablesoncascade = array('usergroup_rights','usergroup_user'); + /** * Constructor de la classe @@ -135,47 +150,23 @@ class UserGroup extends CommonObject { global $conf; - $sql = "SELECT g.rowid, g.entity, g.nom as name, g.note, g.datec, g.tms as datem"; - $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - if ($groupname) + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + if (!empty($groupname)) { - $sql .= " WHERE g.nom = '".$this->db->escape($groupname)."'"; + $result = $this->fetchCommon(0, '', ' AND nom = \''.$this->db->escape($groupname).'\''); } else { - $sql .= " WHERE g.rowid = ".$id; + $result = $this->fetchCommon($id); } - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) + if($result) { - if ($this->db->num_rows($result)) + if ($load_members) { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->entity = $obj->entity; - $this->name = $obj->name; - $this->nom = $obj->name; // Deprecated - $this->note = $obj->note; - $this->datec = $obj->datec; - $this->datem = $obj->datem; - - if ($load_members) - $this->members = $this->listUsersForGroup(); - - - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - - - // Sav current LDAP Current DN - //$this->ldap_dn = $this->_load_ldap_dn($this->_load_ldap_info(),0); + $this->members = $this->listUsersForGroup(); } - $this->db->free($result); + return 1; } else @@ -647,50 +638,7 @@ class UserGroup extends CommonObject */ public function delete(User $user) { - global $conf, $langs; - - $error = 0; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; - $sql .= " WHERE fk_usergroup = ".$this->id; - $this->db->query($sql); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user"; - $sql .= " WHERE fk_usergroup = ".$this->id; - $this->db->query($sql); - - // Remove extrafields - if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used - { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup"; - $sql .= " WHERE rowid = ".$this->id; - $result = $this->db->query($sql); - if ($result) - { - // Call trigger - $result = $this->call_trigger('GROUP_DELETE', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers - - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - dol_print_error($this->db); - return -1; - } + return $this->deleteCommon($user); } /** @@ -701,67 +649,15 @@ class UserGroup extends CommonObject */ public function create($notrigger = 0) { - global $user, $conf, $langs, $hookmanager; + global $user, $conf; - $error = 0; - $now = dol_now(); + $this->datec = dol_now(); if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value - $entity = $this->entity; if (!empty($conf->multicompany->enabled) && $conf->entity == 1) $entity = $this->entity; - $this->db->begin(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup ("; - $sql .= "datec"; - $sql .= ", nom"; - $sql .= ", entity"; - $sql .= ") VALUES ("; - $sql .= "'".$this->db->idate($now)."'"; - $sql .= ",'".$this->db->escape($this->nom)."'"; - $sql .= ",".$this->db->escape($entity); - $sql .= ")"; - - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."usergroup"); - - if ($this->update(1) < 0) return -2; - - $action = 'create'; - - // Actions on extra fields (by external module or standard code) - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('GROUP_CREATE', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers - } - - if ($error > 0) { $error++; $this->db->rollback(); return -1; } - else $this->db->commit(); - - return $this->id; - } - else - { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } + return $this->createCommon($user, $notrigger); } /** @@ -772,9 +668,7 @@ class UserGroup extends CommonObject */ public function update($notrigger = 0) { - global $user, $conf, $langs, $hookmanager; - - $error = 0; + global $user, $conf; $entity = $conf->entity; if (!empty($conf->multicompany->enabled) && $conf->entity == 1) @@ -782,55 +676,7 @@ class UserGroup extends CommonObject $entity = $this->entity; } - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET "; - $sql .= " nom = '".$this->db->escape($this->name)."'"; - $sql .= ", entity = ".$this->db->escape($entity); - $sql .= ", note = '".$this->db->escape($this->note)."'"; - $sql .= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $action = 'update'; - - // Actions on extra fields (by external module or standard code) - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('GROUP_MODIFY', $user); - if ($result < 0) { $error++; } - // End call triggers - } - - if (!$error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -$error; - } - } - else - { - $this->db->rollback(); - dol_print_error($this->db); - return -1; - } + return $this->updateCommon($user, $notrigger); } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index f3ae62beed8..7285c9ad5f3 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -68,16 +68,14 @@ if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global-> } $object = new Usergroup($db); -if ($id > 0) -{ - $object->fetch($id); - $object->getrights(); -} - $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +$object->getrights(); + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('groupcard', 'globalcard')); @@ -325,6 +323,8 @@ else { if ($id) { + $res = $object->fetch_optionals(); + $head = group_prepare_head($object); $title = $langs->trans("Group"); @@ -375,6 +375,8 @@ else print "\n"; } + unset($object->fields['nom']); // Name already displayed in banner + // Common attributes $keyforbreak = ''; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; From 261e6cbc52197460849377a51105a6916d42ac36 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 13 Apr 2020 19:08:03 +0200 Subject: [PATCH 4/6] Fix delete extrafield test --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dcbb25775e7..41a7107b8d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8264,7 +8264,7 @@ abstract class CommonObject } } - if (!$error) + if (!$error && !empty($this->isextrafieldmanaged)) { $result = $this->deleteExtraFields(); if ($result < 0) { $error++; } From 92b6b6e1f56c2e5cdc95b7b02b868360ee2f76c3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 13 Apr 2020 17:16:14 +0000 Subject: [PATCH 5/6] Fixing style errors. --- htdocs/user/group/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 7285c9ad5f3..25a0db9d633 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -90,7 +90,6 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/user/group/list.php'; if (empty($backtopage) || ($cancel && empty($id))) { From 7fea2bc557e84f26e54964d01aa4e46bb624da35 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 15 Apr 2020 08:44:29 +0200 Subject: [PATCH 6/6] Update changelog + trigger name change for class UserGroup --- ChangeLog | 2 +- htdocs/core/class/events.class.php | 6 +++--- htdocs/core/triggers/interface_20_all_Logevents.class.php | 6 +++--- .../triggers/interface_50_modLdap_Ldapsynchro.class.php | 6 +++--- .../interface_99_modZapier_ZapierTriggers.class.php | 6 +++--- .../interface_99_modMyModule_MyModuleTriggers.class.php | 6 +++--- htdocs/user/class/usergroup.class.php | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0de59b03184..68cd7695057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,7 +13,7 @@ For Developers or integrators: - replace $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - remove input field in form '';' - add parameter $pagenavastextinput to value 1 when calling print_barre_liste - +* UserGroup class has been refactored with new architecture. Triggers of class UserGroup are now USERGROUP_CREATE, USERGROUP_MODIFY, USERGROUP_DELETE WARNING: diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index c32fe1d77f2..9c2e5b145dd 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -100,9 +100,9 @@ class Events // extends CommonObject array('id'=>'USER_NEW_PASSWORD', 'test'=>1), array('id'=>'USER_ENABLEDISABLE', 'test'=>1), array('id'=>'USER_DELETE', 'test'=>1), - array('id'=>'GROUP_CREATE', 'test'=>1), - array('id'=>'GROUP_MODIFY', 'test'=>1), - array('id'=>'GROUP_DELETE', 'test'=>1), + array('id'=>'USERGROUP_CREATE', 'test'=>1), + array('id'=>'USERGROUP_MODIFY', 'test'=>1), + array('id'=>'USERGROUP_DELETE', 'test'=>1), ); diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 7acd977e714..fceb1552f0b 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -151,7 +151,7 @@ class InterfaceLogevents extends DolibarrTriggers } // Groupes - elseif ($action == 'GROUP_CREATE') + elseif ($action == 'USERGROUP_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); @@ -159,7 +159,7 @@ class InterfaceLogevents extends DolibarrTriggers $text = $langs->transnoentities("NewGroupCreated", $object->name); $desc = $langs->transnoentities("NewGroupCreated", $object->name); } - elseif ($action == 'GROUP_MODIFY') + elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); @@ -167,7 +167,7 @@ class InterfaceLogevents extends DolibarrTriggers $text = $langs->transnoentities("GroupModified", $object->name); $desc = $langs->transnoentities("GroupModified", $object->name); } - elseif ($action == 'GROUP_DELETE') + elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 2febdacff91..8b8c392615a 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -269,7 +269,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } // Groupes - elseif ($action == 'GROUP_CREATE') + elseif ($action == 'USERGROUP_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') @@ -293,7 +293,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } } - elseif ($action == 'GROUP_MODIFY') + elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') @@ -330,7 +330,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } } - elseif ($action == 'GROUP_DELETE') + elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') diff --git a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php index dc9ca6448a9..1091b5ee198 100644 --- a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php +++ b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php @@ -147,9 +147,9 @@ class InterfaceZapierTriggers extends DolibarrTriggers break; // Groups - //case 'GROUP_CREATE': - //case 'GROUP_MODIFY': - //case 'GROUP_DELETE': + //case 'USERGROUP_CREATE': + //case 'USERGROUP_MODIFY': + //case 'USERGROUP_DELETE': // Companies case 'COMPANY_CREATE': diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index e0dd34cf180..dcee9eeaea5 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -118,9 +118,9 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'ACTION_DELETE': // Groups - //case 'GROUP_CREATE': - //case 'GROUP_MODIFY': - //case 'GROUP_DELETE': + //case 'USERGROUP_CREATE': + //case 'USERGROUP_MODIFY': + //case 'USERGROUP_DELETE': // Companies //case 'COMPANY_CREATE': diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 269089c73f2..aaa631fdf36 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -404,7 +404,7 @@ class UserGroup extends CommonObject $this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : '')); // Call trigger - $result = $this->call_trigger('GROUP_MODIFY', $user); + $result = $this->call_trigger('USERGROUP_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -528,7 +528,7 @@ class UserGroup extends CommonObject $this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : '')); // Call trigger - $result = $this->call_trigger('GROUP_MODIFY', $user); + $result = $this->call_trigger('USERGROUP_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers }