mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: move transversal mode management in multicompany module
This commit is contained in:
parent
e78406e120
commit
ef44dfc472
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans("Groups").'</th>'."\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 '<th class="liste_titre">'.$langs->trans("Entity").'</td>';
|
||||
}
|
||||
print '<th class="liste_titre" align="right">';
|
||||
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 '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans("Groups").'</th>'."\n";
|
||||
print '<th class="liste_titre" align="right">';
|
||||
if ($caneditgroup)
|
||||
{
|
||||
print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
|
||||
print ' ';
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
|
||||
}
|
||||
print '</th></tr>'."\n";
|
||||
|
||||
/*
|
||||
* Groups assigned to user
|
||||
*/
|
||||
if (! empty($groupslist))
|
||||
{
|
||||
foreach($groupslist as $group)
|
||||
{
|
||||
if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
if ($caneditgroup)
|
||||
{
|
||||
print '</td><td>'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/group/card.php?id='.$group->id.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
print img_object($langs->trans("ShowGroup"),"group").' '.$group->name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
}
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
|
||||
}
|
||||
}
|
||||
print '</th></tr>'."\n";
|
||||
|
||||
/*
|
||||
* Groups assigned to user
|
||||
*/
|
||||
if (! empty($groupslist))
|
||||
{
|
||||
foreach($groupslist as $group)
|
||||
{
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
if ($caneditgroup)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/group/card.php?id='.$group->id.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_object($langs->trans("ShowGroup"),"group").' '.$group->name;
|
||||
}
|
||||
print '</td>';
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
if (! empty($group->usergroup_entity))
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
if ($caneditgroup)
|
||||
{
|
||||
$nb=0;
|
||||
foreach($group->usergroup_entity as $group_entity)
|
||||
{
|
||||
$mc->getInfo($group_entity);
|
||||
print ($nb > 0 ? ', ' : '').$mc->label;
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'&entity='.$group_entity.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
print '</a>';
|
||||
$nb++;
|
||||
}
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
print '<td align="right">';
|
||||
if ($caneditgroup && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
else
|
||||
{
|
||||
print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ if ($id > 0 || ! empty($ref))
|
|||
}
|
||||
|
||||
// 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','userdoc','globalcard');
|
||||
$hookmanager->initHooks($contextpage);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -135,7 +136,7 @@ if ($object->id)
|
|||
if ($user->rights->user->user->lire || $user->admin) {
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
}
|
||||
|
||||
|
||||
dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
|
@ -163,7 +164,7 @@ if ($object->id)
|
|||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,159 +65,167 @@ $extrafields = new ExtraFields($db);
|
|||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
$hookmanager->initHooks(array('groupcard','globalcard'));
|
||||
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
||||
$contextpage=array('groupcard','globalcard');
|
||||
$hookmanager->initHooks($contextpage);
|
||||
|
||||
/**
|
||||
* Action remove group
|
||||
* Actions
|
||||
*/
|
||||
if ($action == 'confirm_delete' && $confirm == "yes")
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->delete();
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action add group
|
||||
*/
|
||||
if ($action == 'add')
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
if (! $_POST["nom"]) {
|
||||
setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
|
||||
$action="create"; // Go back to create page
|
||||
} else {
|
||||
$object->nom = trim($_POST["nom"]); // For backward compatibility
|
||||
$object->name = trim($_POST["nom"]);
|
||||
$object->note = trim($_POST["note"]);
|
||||
$parameters=array('id' => $id, 'userid' => $userid, 'caneditperms' => $caneditperms);
|
||||
$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');
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
if (empty($reshook)) {
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
// Action remove group
|
||||
if ($action == 'confirm_delete' && $confirm == "yes")
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->delete();
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
$db->begin();
|
||||
// Action add group
|
||||
if ($action == 'add')
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
if (! $_POST["nom"]) {
|
||||
setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
|
||||
$action="create"; // Go back to create page
|
||||
} else {
|
||||
$object->nom = trim($_POST["nom"]); // For backward compatibility
|
||||
$object->name = trim($_POST["nom"]);
|
||||
$object->note = trim($_POST["note"]);
|
||||
|
||||
$id = $object->create();
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$db->commit();
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$db->begin();
|
||||
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorGroupAlreadyExists",$object->name), null, 'errors');
|
||||
$action="create"; // Go back to create page
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'errors');
|
||||
}
|
||||
}
|
||||
$id = $object->create();
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorGroupAlreadyExists",$object->name), null, 'errors');
|
||||
$action="create"; // Go back to create page
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Add/Remove user into group
|
||||
if ($action == 'adduser' || $action =='removeuser')
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
if ($userid > 0)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$edituser = new User($db);
|
||||
$edituser->fetch($userid);
|
||||
if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,$object->entity);
|
||||
if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,$object->entity);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($edituser->error, $edituser->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$object->fetch($id);
|
||||
|
||||
// Add/Remove user into group
|
||||
if ($action == 'adduser' || $action =='removeuser')
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
if ($userid > 0)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$edituser = new User($db);
|
||||
$edituser->fetch($userid);
|
||||
if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity));
|
||||
if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity));
|
||||
$object->name = trim($_POST["group"]);
|
||||
$object->nom = $object->name; // For backward compatibility
|
||||
$object->note = dol_htmlcleanlastbr($_POST["note"]);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($edituser->error, $edituser->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'errors');
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
|
||||
$ret=$object->update();
|
||||
|
||||
if ($ret >= 0 && ! count($object->errors))
|
||||
{
|
||||
setEventMessages($langs->trans("GroupModified"), null, 'mesgs');
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->usergroup->dir_output;
|
||||
$permissioncreate=$user->rights->user->user->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$object->fetch($id);
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$object->name = trim($_POST["group"]);
|
||||
$object->nom = $object->name; // For backward compatibility
|
||||
$object->note = dol_htmlcleanlastbr($_POST["note"]);
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
|
||||
$ret=$object->update();
|
||||
|
||||
if ($ret >= 0 && ! count($object->errors))
|
||||
{
|
||||
setEventMessages($langs->trans("GroupModified"), null, 'mesgs');
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorForbidden'), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->usergroup->dir_output;
|
||||
$permissioncreate=$user->rights->user->user->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
@ -384,117 +392,87 @@ else
|
|||
// On selectionne les users qui ne sont pas deja dans le groupe
|
||||
$exclude = array();
|
||||
|
||||
if (! empty($object->members))
|
||||
{
|
||||
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)))
|
||||
{
|
||||
foreach($object->members as $useringroup)
|
||||
{
|
||||
$exclude[]=$useringroup->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="adduser">';
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_dolusers('', 'user', 1, $exclude, 0, '', '', $object->entity, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print ' ';
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc))
|
||||
{
|
||||
if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
print '</td><td class="tdtop">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
|
||||
}
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>'."\n";
|
||||
print '</table></form>'."\n";
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Group members
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">'.$langs->trans("Login").'</td>';
|
||||
print '<td class="liste_titre">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td class="liste_titre">'.$langs->trans("Firstname").'</td>';
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1)
|
||||
{
|
||||
print '<td class="liste_titre">'.$langs->trans("Entity").'</td>';
|
||||
}
|
||||
print '<td class="liste_titre" width="5" align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td class="liste_titre" width="5" align="right"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if (! empty($object->members))
|
||||
{
|
||||
foreach($object->members as $useringroup)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login');
|
||||
if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar');
|
||||
else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star');
|
||||
print '</td>';
|
||||
print '<td>'.$useringroup->lastname.'</td>';
|
||||
print '<td>'.$useringroup->firstname.'</td>';
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
if (! empty($useringroup->usergroup_entity))
|
||||
{
|
||||
$nb=0;
|
||||
foreach($useringroup->usergroup_entity as $group_entity)
|
||||
{
|
||||
$mc->getInfo($group_entity);
|
||||
print ($nb > 0 ? ', ' : '').$mc->label;
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removeuser&user='.$useringroup->id.'&entity='.$group_entity.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
print '</a>';
|
||||
$nb++;
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
print '<td align="center">'.$useringroup->getLibStatut(3).'</td>';
|
||||
print '<td align="right">';
|
||||
if (! empty($user->admin) && empty($conf->multicompany->enabled))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removeuser&user='.$useringroup->id.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "-";
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
$exclude[]=$useringroup->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
print "<br>";
|
||||
}
|
||||
|
||||
// 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 '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="adduser">';
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_dolusers('', 'user', 1, $exclude, 0, '', '', $object->entity, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print ' ';
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>'."\n";
|
||||
print '</table></form>'."\n";
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Group members
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">'.$langs->trans("Login").'</td>';
|
||||
print '<td class="liste_titre">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td class="liste_titre">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td class="liste_titre" width="5" align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td class="liste_titre" width="5" align="right"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if (! empty($object->members))
|
||||
{
|
||||
foreach($object->members as $useringroup)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login');
|
||||
if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar');
|
||||
else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star');
|
||||
print '</td>';
|
||||
print '<td>'.$useringroup->lastname.'</td>';
|
||||
print '<td>'.$useringroup->firstname.'</td>';
|
||||
print '<td align="center">'.$useringroup->getLibStatut(3).'</td>';
|
||||
print '<td align="right">';
|
||||
if (! empty($user->admin))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removeuser&user='.$useringroup->id.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "-";
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
print "<br>";
|
||||
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ $object->fetch($id, '', '', 1);
|
|||
$object->getrights();
|
||||
|
||||
// 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','userldap','globalcard');
|
||||
$hookmanager->initHooks($contextpage);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ if ($user->id == $id) $feature2=''; // A user can always read its own card
|
|||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
// 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','usernote','globalcard');
|
||||
$hookmanager->initHooks($contextpage);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -96,11 +97,11 @@ if ($id)
|
|||
if ($user->rights->user->user->lire || $user->admin) {
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
}
|
||||
|
||||
|
||||
dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
print "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ $form = new Form($db);
|
|||
$formadmin=new FormAdmin($db);
|
||||
|
||||
// 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','userihm','globalcard');
|
||||
$hookmanager->initHooks($contextpage);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -188,9 +189,9 @@ if ($action == 'edit')
|
|||
if ($user->rights->user->user->lire || $user->admin) {
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
}
|
||||
|
||||
|
||||
dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{/*
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
|
|
@ -204,7 +205,7 @@ if ($action == 'edit')
|
|||
});
|
||||
});
|
||||
</script>';*/
|
||||
}
|
||||
}
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
|
|
@ -213,16 +214,16 @@ if ($action == 'edit')
|
|||
{
|
||||
if (jQuery("#check_MAIN_LANDING_PAGE").prop("checked")) { jQuery("#MAIN_LANDING_PAGE").removeAttr(\'disabled\'); }
|
||||
else { jQuery("#MAIN_LANDING_PAGE").attr(\'disabled\',\'disabled\'); }
|
||||
|
||||
|
||||
if (jQuery("#check_MAIN_LANG_DEFAULT").prop("checked")) { jQuery("#main_lang_default").removeAttr(\'disabled\'); }
|
||||
else { jQuery("#main_lang_default").attr(\'disabled\',\'disabled\'); }
|
||||
|
||||
|
||||
if (jQuery("#check_SIZE_LISTE_LIMIT").prop("checked")) { jQuery("#main_size_liste_limit").removeAttr(\'disabled\'); }
|
||||
else { jQuery("#main_size_liste_limit").attr(\'disabled\',\'disabled\'); }
|
||||
|
||||
|
||||
if (jQuery("#check_MAIN_THEME").prop("checked")) { jQuery(".themethumbs").removeAttr(\'disabled\'); }
|
||||
else { jQuery(".themethumbs").attr(\'disabled\',\'disabled\'); }
|
||||
|
||||
|
||||
if (jQuery("#check_THEME_ELDY_TOPMENU_BACK1").prop("checked")) { jQuery("#colorpickerTHEME_ELDY_TOPMENU_BACK1").removeAttr(\'disabled\'); }
|
||||
else { jQuery("#colorpickerTHEME_ELDY_TOPMENU_BACK1").attr(\'disabled\',\'disabled\'); }
|
||||
}
|
||||
|
|
@ -236,7 +237,7 @@ if ($action == 'edit')
|
|||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
clearstatcache();
|
||||
$var=true;
|
||||
|
|
@ -245,7 +246,7 @@ if ($action == 'edit')
|
|||
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Parameter").'</td><td width="25%">'.$langs->trans("DefaultValue").'</td><td> </td><td>'.$langs->trans("PersonalValue").'</td></tr>';
|
||||
|
||||
// Landing page
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LandingPage").'</td>';
|
||||
print '<td>';
|
||||
print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE);
|
||||
|
|
@ -257,9 +258,9 @@ if ($action == 'edit')
|
|||
print $form->selectarray('MAIN_LANDING_PAGE', $tmparray, (! empty($object->conf->MAIN_LANDING_PAGE)?$object->conf->MAIN_LANDING_PAGE:''), 0, 0, 0, '', 1);
|
||||
//print info_admin($langs->trans("WarningYouMayLooseAccess"), 0, 0, 0);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Langue par defaut
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Language").'</td>';
|
||||
print '<td>';
|
||||
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
|
||||
|
|
@ -274,7 +275,7 @@ if ($action == 'edit')
|
|||
print '</td></tr>';
|
||||
|
||||
// Taille max des listes
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MaxSizeList").'</td>';
|
||||
print '<td>'.$conf->global->MAIN_SIZE_LISTE_LIMIT.'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_SIZE_LISTE_LIMIT" id="check_SIZE_LISTE_LIMIT" type="checkbox" '.(! empty($object->conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"");
|
||||
|
|
@ -300,18 +301,18 @@ if ($action == 'edit')
|
|||
else
|
||||
{
|
||||
dol_fiche_head($head, 'guisetup', $title, -1, 'user');
|
||||
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
|
||||
$var=true;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Parameter").'</td><td width="25%">'.$langs->trans("DefaultValue").'</td><td> </td><td>'.$langs->trans("PersonalValue").'</td></tr>';
|
||||
|
||||
// Landing page
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LandingPage").'</td>';
|
||||
print '<td>';
|
||||
print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE);
|
||||
|
|
@ -327,9 +328,9 @@ else
|
|||
else print $object->conf->MAIN_LANDING_PAGE;
|
||||
//print $form->selectarray('MAIN_LANDING_PAGE', $tmparray, (! empty($object->conf->MAIN_LANDING_PAGE)?$object->conf->MAIN_LANDING_PAGE:''), 0, 0, 0, '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Language
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Language").'</td>';
|
||||
print '<td>';
|
||||
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
|
||||
|
|
@ -343,7 +344,7 @@ else
|
|||
print (isset($object->conf->MAIN_LANG_DEFAULT) && $object->conf->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):(! empty($object->conf->MAIN_LANG_DEFAULT)?$langs->trans("Language_".$object->conf->MAIN_LANG_DEFAULT):''));
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MaxSizeList").'</td>';
|
||||
print '<td>'.(! empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?$conf->global->MAIN_SIZE_LISTE_LIMIT:' ').'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' type="checkbox" disabled '.(! empty($object->conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ $object->getrights();
|
|||
$entity=$conf->entity;
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$contextpage=array('usercard','globalcard');
|
||||
$contextpage=array('usercard','userperms','globalcard');
|
||||
$hookmanager->initHooks($contextpage);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user