diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php
index 255b476eb61..5b9e62c21df 100644
--- a/htdocs/user/agenda_extsites.php
+++ b/htdocs/user/agenda_extsites.php
@@ -68,7 +68,8 @@ if (($object->id != $user->id) && (! $user->rights->user->user->lire))
accessforbidden();
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('usercard','globalcard'));
+$contextpage=array('usercard','useragenda','globalcard');
+$hookmanager->initHooks($contextpage);
/*
* Actions
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index 09b2fb5b12c..5532bb8137b 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -48,19 +48,13 @@ if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherent
if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$id = GETPOST('id','int');
-$action = GETPOST('action','alpha');
+$action = GETPOST('action','aZ09');
$mode = GETPOST('mode','alpha');
$confirm = GETPOST('confirm','alpha');
$subaction = GETPOST('subaction','alpha');
$group = GETPOST("group","int",3);
$cancel = GETPOST('cancel','alpha');
-// Users/Groups management only in master entity if transverse mode
-if (($action == 'create' || $action == 'adduserldap') && ! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
-{
- accessforbidden();
-}
-
// Define value to know what current user can do on users
$canadduser=(! empty($user->admin) || $user->rights->user->user->creer);
$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire);
@@ -106,7 +100,8 @@ $extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
-$hookmanager->initHooks(array('usercard','globalcard'));
+$contextpage=array('usercard','globalcard');
+$hookmanager->initHooks($contextpage);
@@ -114,7 +109,7 @@ $hookmanager->initHooks(array('usercard','globalcard'));
* Actions
*/
-$parameters=array('id'=>$socid);
+$parameters=array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -279,7 +274,7 @@ if (empty($reshook)) {
}
// Action add usergroup
- if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield)
+ if (($action == 'addgroup' || $action == 'removegroup') && $caneditgroup)
{
if ($group)
{
@@ -289,10 +284,10 @@ if (empty($reshook)) {
$object->fetch($id);
if ($action == 'addgroup') {
- $result = $object->SetInGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity));
+ $result = $object->SetInGroup($group, $editgroup->entity);
}
if ($action == 'removegroup') {
- $result = $object->RemoveFromGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity));
+ $result = $object->RemoveFromGroup($group, $editgroup->entity);
}
if ($result > 0) {
@@ -1706,7 +1701,7 @@ else
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
- if (GETPOST('action','aZ09') != 'presend' && GETPOST('action','aZ09') != 'send')
+ if ($action != 'presend' && $action != 'send')
{
/*
* List of groups of user
@@ -1724,12 +1719,9 @@ else
if (! empty($groupslist))
{
- if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)))
+ foreach($groupslist as $groupforuser)
{
- foreach($groupslist as $groupforuser)
- {
- $exclude[]=$groupforuser->id;
- }
+ $exclude[]=$groupforuser->id;
}
}
@@ -1741,99 +1733,61 @@ else
}
print '
'."\n";
- print '
'.$langs->trans("Groups").'
'."\n";
- if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
+
+ // Other form for add user to group
+ $parameters=array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude);
+ $reshook=$hookmanager->executeHooks('formAddUserToGroup',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ if (empty($reshook))
{
- print '
'.$langs->trans("Entity").'';
- }
- print '
';
- if ($caneditgroup)
- {
- // Users/Groups management only in master entity if transverse mode
- if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
- {
- // nothing
- }
- else
+ print '
";
- print " ";
+ }
+
+ // Other form for add user to group
+ $parameters=array('caneditperms' => $caneditperms, 'exclude' => $exclude);
+ $reshook=$hookmanager->executeHooks('formAddUserToGroup',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ if (empty($reshook))
+ {
+ if ($caneditperms)
+ {
+ print ''."\n";
+ print ' ';
+ }
+
+ /*
+ * Group members
+ */
+ print '
';
+ print '
';
+ print '
'.$langs->trans("Login").'
';
+ print '
'.$langs->trans("Lastname").'
';
+ print '
'.$langs->trans("Firstname").'
';
+ print '
'.$langs->trans("Status").'
';
+ print '
';
+ print "
\n";
+
+ if (! empty($object->members))
+ {
+ foreach($object->members as $useringroup)
+ {
+ print '