Merge pull request #16457 from frederic34/user_code_syntax

code syntax user directory
This commit is contained in:
Laurent Destailleur 2021-02-26 13:25:16 +01:00 committed by GitHub
commit 6e49a0afa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 1866 additions and 1738 deletions

View File

@ -38,13 +38,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'usergroup'; //Must be the $table_element of the class that manage extrafield $elementtype = 'usergroup'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -79,8 +83,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -93,8 +96,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -106,8 +108,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -37,13 +37,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'user'; //Must be the $table_element of the class that manage extrafield $elementtype = 'user'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -78,8 +82,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -92,8 +95,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -105,8 +107,7 @@ if ($action == 'create')
/* Editing an optional field */ /* Editing an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -41,7 +41,9 @@ $actiontest = GETPOST('test', 'alpha');
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useragenda'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useragenda'; // To manage different context of search
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; if (empty($conf->global->AGENDA_EXT_NB)) {
$conf->global->AGENDA_EXT_NB = 5;
}
$MAXAGENDA = $conf->global->AGENDA_EXT_NB; $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
// List of available colors // List of available colors
@ -55,14 +57,17 @@ $object->getrights();
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
// If user is not user that read and no permission to read other users, we stop // If user is not user that read and no permission to read other users, we stop
if (($object->id != $user->id) && (!$user->rights->user->user->lire)) if (($object->id != $user->id) && (!$user->rights->user->user->lire)) {
accessforbidden(); accessforbidden();
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); $hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard'));
@ -73,7 +78,9 @@ $hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
if ($actionsave) { if ($actionsave) {
@ -168,7 +175,11 @@ print '<span class="opacitymedium">'.$langs->trans("AgendaExtSitesDesc")."</span
print "<br>\n"; print "<br>\n";
$selectedvalue = $conf->global->AGENDA_DISABLE_EXT; $selectedvalue = $conf->global->AGENDA_DISABLE_EXT;
if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; if ($selectedvalue == 1) {
$selectedvalue = 0;
} else {
$selectedvalue = 1;
}
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
@ -183,8 +194,7 @@ print '<td class="right">'.$langs->trans("Color").'</td>';
print "</tr>"; print "</tr>";
$i = 1; $i = 1;
while ($i <= $MAXAGENDA) while ($i <= $MAXAGENDA) {
{
$key = $i; $key = $i;
$name = 'AGENDA_EXT_NAME_'.$id.'_'.$key; $name = 'AGENDA_EXT_NAME_'.$id.'_'.$key;
$src = 'AGENDA_EXT_SRC_'.$id.'_'.$key; $src = 'AGENDA_EXT_SRC_'.$id.'_'.$key;

View File

@ -32,9 +32,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; if (!empty($conf->holiday->enabled)) {
if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; }
if (!empty($conf->expensereport->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
}
if (!empty($conf->salaries->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
}
// Load translation files required by page // Load translation files required by page
$langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries')); $langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries'));
@ -47,35 +53,44 @@ $cancel = GETPOST('cancel', 'alpha');
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
// Ok if user->rights->salaries->read or user->rights->hrm->read // Ok if user->rights->salaries->read or user->rights->hrm->read
//$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2);
$ok = false; $ok = false;
if ($user->id == $id) $ok = true; // A user can always read its own card if ($user->id == $id) {
if (!empty($user->rights->salaries->read)) $ok = true; $ok = true; // A user can always read its own card
if (!empty($user->rights->hrm->read)) $ok = true; }
if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok = true; if (!empty($user->rights->salaries->read)) {
if (!$ok) $ok = true;
{ }
if (!empty($user->rights->hrm->read)) {
$ok = true;
}
if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) {
$ok = true;
}
if (!$ok) {
accessforbidden(); accessforbidden();
} }
$object = new User($db); $object = new User($db);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{
$result = $object->fetch($id, $ref, '', 1); $result = $object->fetch($id, $ref, '', 1);
$object->getrights(); $object->getrights();
} }
$account = new UserBankAccount($db); $account = new UserBankAccount($db);
if (!$bankid) if (!$bankid) {
{
$account->fetch(0, '', $id); $account->fetch(0, '', $id);
} else { } else {
$account->fetch($bankid); $account->fetch($bankid);
} }
if (empty($account->userid)) $account->userid = $object->id; if (empty($account->userid)) {
$account->userid = $object->id;
}
$permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer)); $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer));
@ -84,8 +99,7 @@ $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty(
* Actions * Actions
*/ */
if ($action == 'add' && !$cancel) if ($action == 'add' && !$cancel) {
{
$account->userid = $object->id; $account->userid = $object->id;
$account->bank = GETPOST('bank', 'alpha'); $account->bank = GETPOST('bank', 'alpha');
@ -103,8 +117,7 @@ if ($action == 'add' && !$cancel)
$result = $account->create($user); $result = $account->create($user);
if (!$result) if (!$result) {
{
setEventMessages($account->error, $account->errors, 'errors'); setEventMessages($account->error, $account->errors, 'errors');
$action = 'edit'; // Force chargement page edition $action = 'edit'; // Force chargement page edition
} else { } else {
@ -113,8 +126,7 @@ if ($action == 'add' && !$cancel)
} }
} }
if ($action == 'update' && !$cancel) if ($action == 'update' && !$cancel) {
{
$account->userid = $object->id; $account->userid = $object->id;
/* /*
@ -188,28 +200,36 @@ if ($action == 'update' && !$cancel)
if ($action == 'setpersonal_email') { if ($action == 'setpersonal_email') {
$object->personal_email = (string) GETPOST('personal_email', 'alphanohtml'); $object->personal_email = (string) GETPOST('personal_email', 'alphanohtml');
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} }
// update personal mobile // update personal mobile
if ($action == 'setpersonal_mobile') { if ($action == 'setpersonal_mobile') {
$object->personal_mobile = (string) GETPOST('personal_mobile', 'alphanohtml'); $object->personal_mobile = (string) GETPOST('personal_mobile', 'alphanohtml');
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} }
// update default_c_exp_tax_cat // update default_c_exp_tax_cat
if ($action == 'setdefault_c_exp_tax_cat') { if ($action == 'setdefault_c_exp_tax_cat') {
$object->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat', 'int'); $object->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat', 'int');
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} }
// update default range // update default range
if ($action == 'setdefault_range') { if ($action == 'setdefault_range') {
$object->default_range = GETPOST('default_range', 'int'); $object->default_range = GETPOST('default_range', 'int');
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} }
@ -226,16 +246,14 @@ llxHeader(null, $langs->trans("BankAccounts"));
$head = user_prepare_head($object); $head = user_prepare_head($object);
if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) {
{
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">'; print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">';
print '<input type="hidden" name="bankid" value="'.$bankid.'">'; print '<input type="hidden" name="bankid" value="'.$bankid.'">';
} }
if ($id && $action == 'create' && $user->rights->user->user->creer) if ($id && $action == 'create' && $user->rights->user->user->creer) {
{
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
@ -244,8 +262,7 @@ if ($id && $action == 'create' && $user->rights->user->user->creer)
// View // View
if ($action != 'edit' && $action != 'create') // If not bank account yet, $account may be empty if ($action != 'edit' && $action != 'create') { // If not bank account yet, $account may be empty
{
$title = $langs->trans("User"); $title = $langs->trans("User");
print dol_get_fiche_head($head, 'bank', $title, -1, 'user'); print dol_get_fiche_head($head, 'bank', $title, -1, 'user');
@ -283,8 +300,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
{
print '<tr class="nowrap">'; print '<tr class="nowrap">';
print '<td>'; print '<td>';
print $form->editfieldkey("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer); print $form->editfieldkey("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer);
@ -338,8 +354,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
// Latest payments of salaries // Latest payments of salaries
if (!empty($conf->salaries->enabled) && if (!empty($conf->salaries->enabled) &&
$user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id) $user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id)
) ) {
{
$salary = new PaymentSalary($db); $salary = new PaymentSalary($db);
$sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount"; $sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount";
@ -349,8 +364,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
$sql .= " ORDER BY ps.datesp DESC"; $sql .= " ORDER BY ps.datesp DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -361,8 +375,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '</tr>'; print '</tr>';
$i = 0; $i = 0;
while ($i < $num && $i < $MAXLIST) while ($i < $num && $i < $MAXLIST) {
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -381,7 +394,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
} }
$db->free($resql); $db->free($resql);
if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; if ($num <= 0) {
print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>';
}
print "</table>"; print "</table>";
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -393,8 +408,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
*/ */
if (!empty($conf->holiday->enabled) && if (!empty($conf->holiday->enabled) &&
($user->rights->holiday->readall || ($user->rights->holiday->read && $object->id == $user->id)) ($user->rights->holiday->readall || ($user->rights->holiday->read && $object->id == $user->id))
) ) {
{
$holiday = new Holiday($db); $holiday = new Holiday($db);
$sql = "SELECT h.rowid, h.statut as status, h.fk_type, h.date_debut, h.date_fin, h.halfday"; $sql = "SELECT h.rowid, h.statut as status, h.fk_type, h.date_debut, h.date_fin, h.halfday";
@ -404,8 +418,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
$sql .= " ORDER BY h.date_debut DESC"; $sql .= " ORDER BY h.date_debut DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -416,8 +429,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '</tr>'; print '</tr>';
$i = 0; $i = 0;
while ($i < $num && $i < $MAXLIST) while ($i < $num && $i < $MAXLIST) {
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$holiday->id = $objp->rowid; $holiday->id = $objp->rowid;
@ -436,7 +448,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
} }
$db->free($resql); $db->free($resql);
if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; if ($num <= 0) {
print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>';
}
print "</table>"; print "</table>";
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -448,8 +462,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
*/ */
if (!empty($conf->expensereport->enabled) && if (!empty($conf->expensereport->enabled) &&
($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id)) ($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id))
) ) {
{
$exp = new ExpenseReport($db); $exp = new ExpenseReport($db);
$sql = "SELECT e.rowid, e.ref, e.fk_statut as status, e.date_debut, e.total_ttc"; $sql = "SELECT e.rowid, e.ref, e.fk_statut as status, e.date_debut, e.total_ttc";
@ -459,8 +472,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
$sql .= " ORDER BY e.date_debut DESC"; $sql .= " ORDER BY e.date_debut DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -471,8 +483,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '</tr>'; print '</tr>';
$i = 0; $i = 0;
while ($i < $num && $i < $MAXLIST) while ($i < $num && $i < $MAXLIST) {
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$exp->id = $objp->rowid; $exp->id = $objp->rowid;
@ -490,7 +501,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
} }
$db->free($resql); $db->free($resql);
if ($num <= 0) print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>'; if ($num <= 0) {
print '<td colspan="4" class="opacitymedium">'.$langs->trans("None").'</a>';
}
print "</table>"; print "</table>";
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -589,8 +602,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
} }
if ($account->id == 0) if ($account->id == 0) {
{
$colspan = 6; $colspan = 6;
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
} }
@ -600,8 +612,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
} }
// Edit // Edit
if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer) if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer) {
{
$title = $langs->trans("User"); $title = $langs->trans("User");
print dol_get_fiche_head($head, 'bank', $title, 0, 'user'); print dol_get_fiche_head($head, 'bank', $title, 0, 'user');
@ -679,9 +690,13 @@ if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->us
print '</div>'; print '</div>';
} }
if ($id && $action == 'edit' && $user->rights->user->user->creer) print '</form>'; if ($id && $action == 'edit' && $user->rights->user->user->creer) {
print '</form>';
}
if ($id && $action == 'create' && $user->rights->user->user->creer) print '</form>'; if ($id && $action == 'create' && $user->rights->user->user->creer) {
print '</form>';
}
// End of page // End of page
llxFooter(); llxFooter();

File diff suppressed because it is too large Load Diff

View File

@ -96,10 +96,8 @@ class UserBankAccount extends Account
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rib (fk_user, datec)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rib (fk_user, datec)";
$sql .= " VALUES (".$this->userid.", '".$this->db->idate($now)."')"; $sql .= " VALUES (".$this->userid.", '".$this->db->idate($now)."')";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->affected_rows($resql)) {
if ($this->db->affected_rows($resql))
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib");
return $this->update($user); return $this->update($user);
@ -121,8 +119,7 @@ class UserBankAccount extends Account
{ {
global $conf; global $conf;
if (!$this->id) if (!$this->id) {
{
$this->create(); $this->create();
} }
@ -138,14 +135,15 @@ class UserBankAccount extends Account
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
if (trim($this->label) != '') if (trim($this->label) != '') {
$sql .= ",label = '".$this->db->escape($this->label)."'"; $sql .= ",label = '".$this->db->escape($this->label)."'";
else $sql .= ",label = NULL"; } else {
$sql .= ",label = NULL";
}
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
return 1; return 1;
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
@ -163,20 +161,26 @@ class UserBankAccount extends Account
*/ */
public function fetch($id, $ref = '', $userid = 0) public function fetch($id, $ref = '', $userid = 0)
{ {
if (empty($id) && empty($ref) && empty($userid)) return -1; if (empty($id) && empty($ref) && empty($userid)) {
return -1;
}
$sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; $sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, label, datec, tms as datem"; $sql .= " owner_address, label, datec, tms as datem";
$sql .= " FROM ".MAIN_DB_PREFIX."user_rib"; $sql .= " FROM ".MAIN_DB_PREFIX."user_rib";
if ($id) $sql .= " WHERE rowid = ".$id; if ($id) {
if ($ref) $sql .= " WHERE label = '".$this->db->escape($ref)."'"; $sql .= " WHERE rowid = ".$id;
if ($userid) $sql .= " WHERE fk_user = ".((int) $userid); }
if ($ref) {
$sql .= " WHERE label = '".$this->db->escape($ref)."'";
}
if ($userid) {
$sql .= " WHERE fk_user = ".((int) $userid);
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->num_rows($resql)) {
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;

View File

@ -28,7 +28,9 @@
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; if (!empty($conf->ldap->enabled)) {
require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
}
/** /**
@ -154,8 +156,7 @@ class UserGroup extends CommonObject
global $conf; global $conf;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
if (!empty($groupname)) if (!empty($groupname)) {
{
$result = $this->fetchCommon(0, '', ' AND nom = \''.$this->db->escape($groupname).'\''); $result = $this->fetchCommon(0, '', ' AND nom = \''.$this->db->escape($groupname).'\'');
} else { } else {
$result = $this->fetchCommon($id); $result = $this->fetchCommon($id);
@ -163,10 +164,8 @@ class UserGroup extends CommonObject
$this->name = $this->nom; // For compatibility with field name $this->name = $this->nom; // For compatibility with field name
if ($result) if ($result) {
{ if ($load_members) {
if ($load_members)
{
$this->members = $this->listUsersForGroup(); $this->members = $this->listUsersForGroup();
} }
@ -196,8 +195,7 @@ class UserGroup extends CommonObject
$sql .= " ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= " ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE ug.fk_usergroup = g.rowid"; $sql .= " WHERE ug.fk_usergroup = g.rowid";
$sql .= " AND ug.fk_user = ".$userid; $sql .= " AND ug.fk_user = ".$userid;
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
{
$sql .= " AND g.entity IS NOT NULL"; $sql .= " AND g.entity IS NOT NULL";
} else { } else {
$sql .= " AND g.entity IN (0,".$conf->entity.")"; $sql .= " AND g.entity IN (0,".$conf->entity.")";
@ -206,12 +204,9 @@ class UserGroup extends CommonObject
dol_syslog(get_class($this)."::listGroupsForUser", LOG_DEBUG); dol_syslog(get_class($this)."::listGroupsForUser", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ while ($obj = $this->db->fetch_object($result)) {
while ($obj = $this->db->fetch_object($result)) if (!array_key_exists($obj->rowid, $ret)) {
{
if (!array_key_exists($obj->rowid, $ret))
{
$newgroup = new UserGroup($this->db); $newgroup = new UserGroup($this->db);
$newgroup->fetch($obj->rowid, '', $load_members); $newgroup->fetch($obj->rowid, '', $load_members);
$ret[$obj->rowid] = $newgroup; $ret[$obj->rowid] = $newgroup;
@ -243,37 +238,43 @@ class UserGroup extends CommonObject
$ret = array(); $ret = array();
$sql = "SELECT u.rowid"; $sql = "SELECT u.rowid";
if (!empty($this->id)) $sql .= ", ug.entity as usergroup_entity"; if (!empty($this->id)) {
$sql .= ", ug.entity as usergroup_entity";
}
$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
if (!empty($this->id)) $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; if (!empty($this->id)) {
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
}
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
if (!empty($this->id)) $sql .= " AND ug.fk_user = u.rowid"; if (!empty($this->id)) {
if (!empty($this->id)) $sql .= " AND ug.fk_usergroup = ".$this->id; $sql .= " AND ug.fk_user = u.rowid";
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) }
{ if (!empty($this->id)) {
$sql .= " AND ug.fk_usergroup = ".$this->id;
}
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
$sql .= " AND u.entity IS NOT NULL"; $sql .= " AND u.entity IS NOT NULL";
} else { } else {
$sql .= " AND u.entity IN (0,".$conf->entity.")"; $sql .= " AND u.entity IN (0,".$conf->entity.")";
} }
if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')'; if (!empty($excludefilter)) {
$sql .= ' AND ('.$excludefilter.')';
}
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG); dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ while ($obj = $this->db->fetch_object($resql)) {
while ($obj = $this->db->fetch_object($resql)) if (!array_key_exists($obj->rowid, $ret)) {
{ if ($mode != 1) {
if (!array_key_exists($obj->rowid, $ret))
{
if ($mode != 1)
{
$newuser = new User($this->db); $newuser = new User($this->db);
$newuser->fetch($obj->rowid); $newuser->fetch($obj->rowid);
$ret[$obj->rowid] = $newuser; $ret[$obj->rowid] = $newuser;
} else $ret[$obj->rowid] = $obj->rowid; } else {
$ret[$obj->rowid] = $obj->rowid;
} }
if ($mode != 1 && !empty($obj->usergroup_entity)) }
{ if ($mode != 1 && !empty($obj->usergroup_entity)) {
$ret[$obj->rowid]->usergroup_entity[] = $obj->usergroup_entity; $ret[$obj->rowid]->usergroup_entity[] = $obj->usergroup_entity;
} }
} }
@ -308,8 +309,7 @@ class UserGroup extends CommonObject
$this->db->begin(); $this->db->begin();
if (!empty($rid)) if (!empty($rid)) {
{
$module = $perms = $subperms = ''; $module = $perms = $subperms = '';
// Si on a demande ajout d'un droit en particulier, on recupere // Si on a demande ajout d'un droit en particulier, on recupere
@ -335,25 +335,27 @@ class UserGroup extends CommonObject
// Where pour la liste des droits a ajouter // Where pour la liste des droits a ajouter
$whereforadd = "id=".((int) $rid); $whereforadd = "id=".((int) $rid);
// Find also rights that are herited to add them too // Find also rights that are herited to add them too
if ($subperms) $whereforadd .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND (subperms='lire' OR subperms='read'))"; if ($subperms) {
elseif ($perms) $whereforadd .= " OR (module='".$this->db->escape($module)."' AND (perms='lire' OR perms='read') AND subperms IS NULL)"; $whereforadd .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND (subperms='lire' OR subperms='read'))";
} elseif ($perms) {
$whereforadd .= " OR (module='".$this->db->escape($module)."' AND (perms='lire' OR perms='read') AND subperms IS NULL)";
}
} else { } else {
// Where pour la liste des droits a ajouter // Where pour la liste des droits a ajouter
if (!empty($allmodule)) if (!empty($allmodule)) {
{ if ($allmodule == 'allmodules') {
if ($allmodule == 'allmodules')
{
$whereforadd = 'allmodules'; $whereforadd = 'allmodules';
} else { } else {
$whereforadd = "module='".$this->db->escape($allmodule)."'"; $whereforadd = "module='".$this->db->escape($allmodule)."'";
if (!empty($allperms)) $whereforadd .= " AND perms='".$this->db->escape($allperms)."'"; if (!empty($allperms)) {
$whereforadd .= " AND perms='".$this->db->escape($allperms)."'";
}
} }
} }
} }
// Add permission of the list $whereforadd // Add permission of the list $whereforadd
if (!empty($whereforadd)) if (!empty($whereforadd)) {
{
//print "$module-$perms-$subperms"; //print "$module-$perms-$subperms";
$sql = "SELECT id"; $sql = "SELECT id";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
@ -363,19 +365,21 @@ class UserGroup extends CommonObject
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$nid = $obj->id; $nid = $obj->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid." AND entity = ".$entity; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid." AND entity = ".$entity;
if (!$this->db->query($sql)) $error++; if (!$this->db->query($sql)) {
$error++;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")";
if (!$this->db->query($sql)) $error++; if (!$this->db->query($sql)) {
$error++;
}
$i++; $i++;
} }
@ -384,14 +388,15 @@ class UserGroup extends CommonObject
dol_print_error($this->db); dol_print_error($this->db);
} }
if (!$error) if (!$error) {
{
$langs->load("other"); $langs->load("other");
$this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : '')); $this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : ''));
// Call trigger // Call trigger
$result = $this->call_trigger('USERGROUP_MODIFY', $user); $result = $this->call_trigger('USERGROUP_MODIFY', $user);
if ($result < 0) { $error++; } if ($result < 0) {
$error++;
}
// End call triggers // End call triggers
} }
} }
@ -426,8 +431,7 @@ class UserGroup extends CommonObject
$this->db->begin(); $this->db->begin();
if (!empty($rid)) if (!empty($rid)) {
{
$module = $perms = $subperms = ''; $module = $perms = $subperms = '';
// Si on a demande supression d'un droit en particulier, on recupere // Si on a demande supression d'un droit en particulier, on recupere
@ -453,29 +457,32 @@ class UserGroup extends CommonObject
// Where pour la liste des droits a supprimer // Where pour la liste des droits a supprimer
$wherefordel = "id=".$this->db->escape($rid); $wherefordel = "id=".$this->db->escape($rid);
// Suppression des droits induits // Suppression des droits induits
if ($subperms == 'lire' || $subperms == 'read') $wherefordel .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND subperms IS NOT NULL)"; if ($subperms == 'lire' || $subperms == 'read') {
if ($perms == 'lire' || $perms == 'read') $wherefordel .= " OR (module='".$this->db->escape($module)."')"; $wherefordel .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND subperms IS NOT NULL)";
}
if ($perms == 'lire' || $perms == 'read') {
$wherefordel .= " OR (module='".$this->db->escape($module)."')";
}
// Pour compatibilite, si lowid = 0, on est en mode suppression de tout // Pour compatibilite, si lowid = 0, on est en mode suppression de tout
// TODO A virer quand sera gere par l'appelant // TODO A virer quand sera gere par l'appelant
//if (substr($rid,-1,1) == 0) $wherefordel="module='$module'"; //if (substr($rid,-1,1) == 0) $wherefordel="module='$module'";
} else { } else {
// Add permission of the list $wherefordel // Add permission of the list $wherefordel
if (!empty($allmodule)) if (!empty($allmodule)) {
{ if ($allmodule == 'allmodules') {
if ($allmodule == 'allmodules')
{
$wherefordel = 'allmodules'; $wherefordel = 'allmodules';
} else { } else {
$wherefordel = "module='".$this->db->escape($allmodule)."'"; $wherefordel = "module='".$this->db->escape($allmodule)."'";
if (!empty($allperms)) $wherefordel .= " AND perms='".$this->db->escape($allperms)."'"; if (!empty($allperms)) {
$wherefordel .= " AND perms='".$this->db->escape($allperms)."'";
}
} }
} }
} }
// Suppression des droits de la liste wherefordel // Suppression des droits de la liste wherefordel
if (!empty($wherefordel)) if (!empty($wherefordel)) {
{
//print "$module-$perms-$subperms"; //print "$module-$perms-$subperms";
$sql = "SELECT id"; $sql = "SELECT id";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
@ -485,12 +492,10 @@ class UserGroup extends CommonObject
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$nid = 0; $nid = 0;
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@ -501,7 +506,9 @@ class UserGroup extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
$sql .= " WHERE fk_usergroup = $this->id AND fk_id=".$nid; $sql .= " WHERE fk_usergroup = $this->id AND fk_id=".$nid;
$sql .= " AND entity = ".$entity; $sql .= " AND entity = ".$entity;
if (!$this->db->query($sql)) $error++; if (!$this->db->query($sql)) {
$error++;
}
$i++; $i++;
} }
@ -510,14 +517,15 @@ class UserGroup extends CommonObject
dol_print_error($this->db); dol_print_error($this->db);
} }
if (!$error) if (!$error) {
{
$langs->load("other"); $langs->load("other");
$this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : '')); $this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : ''));
// Call trigger // Call trigger
$result = $this->call_trigger('USERGROUP_MODIFY', $user); $result = $this->call_trigger('USERGROUP_MODIFY', $user);
if ($result < 0) { $error++; } if ($result < 0) {
$error++;
}
// End call triggers // End call triggers
} }
} }
@ -542,14 +550,12 @@ class UserGroup extends CommonObject
{ {
global $conf; global $conf;
if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) {
{
// Rights for this module are already loaded, so we leave // Rights for this module are already loaded, so we leave
return; return;
} }
if (!empty($this->all_permissions_are_loaded)) if (!empty($this->all_permissions_are_loaded)) {
{
// We already loaded all rights for this group, so we leave // We already loaded all rights for this group, so we leave
return; return;
} }
@ -564,16 +570,16 @@ class UserGroup extends CommonObject
$sql .= " AND u.entity = ".$conf->entity; $sql .= " AND u.entity = ".$conf->entity;
$sql .= " AND u.fk_usergroup = ".$this->id; $sql .= " AND u.fk_usergroup = ".$this->id;
$sql .= " AND r.perms IS NOT NULL"; $sql .= " AND r.perms IS NOT NULL";
if ($moduletag) $sql .= " AND r.module = '".$this->db->escape($moduletag)."'"; if ($moduletag) {
$sql .= " AND r.module = '".$this->db->escape($moduletag)."'";
}
dol_syslog(get_class($this).'::getrights', LOG_DEBUG); dol_syslog(get_class($this).'::getrights', LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) { if ($obj) {
@ -581,17 +587,25 @@ class UserGroup extends CommonObject
$perms = $obj->perms; $perms = $obj->perms;
$subperms = $obj->subperms; $subperms = $obj->subperms;
if ($perms) if ($perms) {
{ if (!isset($this->rights)) {
if (!isset($this->rights)) $this->rights = new stdClass(); // For avoid error $this->rights = new stdClass(); // For avoid error
if (!isset($this->rights->$module) || !is_object($this->rights->$module)) $this->rights->$module = new stdClass(); }
if ($subperms) if (!isset($this->rights->$module) || !is_object($this->rights->$module)) {
{ $this->rights->$module = new stdClass();
if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); }
if (empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; if ($subperms) {
if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) {
$this->rights->$module->$perms = new stdClass();
}
if (empty($this->rights->$module->$perms->$subperms)) {
$this->nb_rights++;
}
$this->rights->$module->$perms->$subperms = 1; $this->rights->$module->$perms->$subperms = 1;
} else { } else {
if (empty($this->rights->$module->$perms)) $this->nb_rights++; if (empty($this->rights->$module->$perms)) {
$this->nb_rights++;
}
$this->rights->$module->$perms = 1; $this->rights->$module->$perms = 1;
} }
} }
@ -602,8 +616,7 @@ class UserGroup extends CommonObject
$this->db->free($resql); $this->db->free($resql);
} }
if ($moduletag == '') if ($moduletag == '') {
{
// Si module etait non defini, alors on a tout charge, on peut donc considerer // Si module etait non defini, alors on a tout charge, on peut donc considerer
// que les droits sont en cache (car tous charges) pour cet instance de group // que les droits sont en cache (car tous charges) pour cet instance de group
$this->all_permissions_are_loaded = 1; $this->all_permissions_are_loaded = 1;
@ -641,7 +654,9 @@ class UserGroup extends CommonObject
$this->nom = $this->name; // Field for 'name' is called 'nom' in database $this->nom = $this->name; // Field for 'name' is called 'nom' in database
} }
if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value if (!isset($this->entity)) {
$this->entity = $conf->entity; // If not defined, we use default value
}
return $this->createCommon($user, $notrigger); return $this->createCommon($user, $notrigger);
} }
@ -708,7 +723,9 @@ class UserGroup extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) $withpicto = 0; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) {
$withpicto = 0;
}
$result = ''; $label = ''; $result = ''; $label = '';
@ -720,19 +737,20 @@ class UserGroup extends CommonObject
$url = DOL_URL_ROOT.'/user/group/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/user/group/card.php?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ""; $linkclose = "";
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$langs->load("users"); $langs->load("users");
$label = $langs->trans("ShowGroup"); $label = $langs->trans("ShowGroup");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"';
@ -753,16 +771,23 @@ class UserGroup extends CommonObject
$linkend = '</a>'; $linkend = '</a>';
$result = $linkstart; $result = $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) {
if ($withpicto != 2) $result .= $this->name; $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->name;
}
$result .= $linkend; $result .= $linkend;
global $action; global $action;
$hookmanager->initHooks(array('groupdao')); $hookmanager->initHooks(array('groupdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint; if ($reshook > 0) {
else $result .= $hookmanager->resPrint; $result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }
@ -783,9 +808,15 @@ class UserGroup extends CommonObject
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$dn = ''; $dn = '';
if ($mode == 0) $dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_GROUP_DN; if ($mode == 0) {
if ($mode == 1) $dn = $conf->global->LDAP_GROUP_DN; $dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_GROUP_DN;
if ($mode == 2) $dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS]; }
if ($mode == 1) {
$dn = $conf->global->LDAP_GROUP_DN;
}
if ($mode == 2) {
$dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS];
}
return $dn; return $dn;
} }
@ -808,14 +839,16 @@ class UserGroup extends CommonObject
$info["objectclass"] = explode(',', $conf->global->LDAP_GROUP_OBJECT_CLASS); $info["objectclass"] = explode(',', $conf->global->LDAP_GROUP_OBJECT_CLASS);
// Champs // Champs
if ($this->name && !empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) $info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name; if ($this->name && !empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) {
$info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name;
}
//if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_NAME)) $info[$conf->global->LDAP_GROUP_FIELD_NAME] = $this->name; //if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_NAME)) $info[$conf->global->LDAP_GROUP_FIELD_NAME] = $this->name;
if ($this->note && !empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 2); if ($this->note && !empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) {
if (!empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 2);
{ }
if (!empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)) {
$valueofldapfield = array(); $valueofldapfield = array();
foreach ($this->members as $key=>$val) // This is array of users for group into dolibarr database. foreach ($this->members as $key => $val) { // This is array of users for group into dolibarr database.
{
$muser = new User($this->db); $muser = new User($this->db);
$muser->fetch($val->id); $muser->fetch($val->id);
$info2 = $muser->_load_ldap_info(); $info2 = $muser->_load_ldap_info();
@ -875,10 +908,8 @@ class UserGroup extends CommonObject
$langs->load("user"); $langs->load("user");
// Positionne le modele sur le nom du modele a utiliser // Positionne le modele sur le nom du modele a utiliser
if (!dol_strlen($modele)) if (!dol_strlen($modele)) {
{ if (!empty($conf->global->USERGROUP_ADDON_PDF)) {
if (!empty($conf->global->USERGROUP_ADDON_PDF))
{
$modele = $conf->global->USERGROUP_ADDON_PDF; $modele = $conf->global->USERGROUP_ADDON_PDF;
} else { } else {
$modele = 'grass'; $modele = 'grass';

View File

@ -33,7 +33,9 @@ $id = (int) GETPOST('id', 'int');
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
@ -47,7 +49,9 @@ $hookmanager->initHooks(array('usercard', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
if ($action == 'update' && !GETPOST('cancel', 'alpha')) { if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
@ -76,8 +80,7 @@ $form = new Form($db);
llxHeader("", "ClickToDial"); llxHeader("", "ClickToDial");
if ($id > 0) if ($id > 0) {
{
$object = new User($db); $object = new User($db);
$object->fetch($id, '', '', 1); $object->fetch($id, '', '', 1);
$object->getrights(); $object->getrights();
@ -107,17 +110,14 @@ if ($id > 0)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
// Edit mode // Edit mode
if ($action == 'edit') if ($action == 'edit') {
{
print '<table class="border centpercent">'; print '<table class="border centpercent">';
if ($user->admin) if ($user->admin) {
{
print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>'; print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
print '<td class="valeur">'; print '<td class="valeur">';
print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">'; print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) {
{
$langs->load("errors"); $langs->load("errors");
print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>'; print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>';
} else { } else {
@ -147,14 +147,14 @@ if ($id > 0)
{ {
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
if (!empty($user->admin)) if (!empty($user->admin)) {
{
print '<tr><td class="titlefield">ClickToDial URL</td>'; print '<tr><td class="titlefield">ClickToDial URL</td>';
print '<td class="valeur">'; print '<td class="valeur">';
$url = $conf->global->CLICKTODIAL_URL; $url = $conf->global->CLICKTODIAL_URL;
if (!empty($object->clicktodial_url)) $url = $object->clicktodial_url; if (!empty($object->clicktodial_url)) {
if (empty($url)) $url = $object->clicktodial_url;
{ }
if (empty($url)) {
$langs->load("errors"); $langs->load("errors");
print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>'; print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>';
} else { } else {
@ -181,8 +181,7 @@ if ($id > 0)
print dol_get_fiche_end(); print dol_get_fiche_end();
if ($action == 'edit') if ($action == 'edit') {
{
print '<br>'; print '<br>';
print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">'; print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
@ -198,8 +197,7 @@ if ($id > 0)
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if (!empty($user->admin) && $action <> 'edit') if (!empty($user->admin) && $action <> 'edit') {
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
} }

View File

@ -47,14 +47,12 @@ $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
$candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer); $candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer);
$canreadgroup = $canreaduser; $canreadgroup = $canreaduser;
$caneditgroup = $canedituser; $caneditgroup = $canedituser;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read); $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read);
$caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write);
} }
// Define value to know what current user can do on properties of edited user // Define value to know what current user can do on properties of edited user
if ($id) if ($id) {
{
// $user est le user qui edite, $id est l'id de l'utilisateur edite // $user est le user qui edite, $id est l'id de l'utilisateur edite
$caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer)
|| (($user->id != $id) && $user->rights->user->user->creer)); || (($user->id != $id) && $user->rights->user->user->creer));
@ -64,28 +62,37 @@ if ($id)
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = 'user'; $feature2 = 'user';
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
if ($user->id <> $id && !$canreaduser) accessforbidden(); if ($user->id <> $id && !$canreaduser) {
accessforbidden();
}
// Get parameters // Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } if (empty($page) || $page == -1) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "position_name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "position_name";
}
$object = new User($db); $object = new User($db);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{
$result = $object->fetch($id, $ref, '', 1); $result = $object->fetch($id, $ref, '', 1);
$object->getrights(); $object->getrights();
//$upload_dir = $conf->user->multidir_output[$object->entity] . "/" . $object->id ; //$upload_dir = $conf->user->multidir_output[$object->entity] . "/" . $object->id ;
@ -103,7 +110,9 @@ $hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
@ -118,12 +127,13 @@ $form = new Form($db);
llxHeader('', $langs->trans("UserCard").' - '.$langs->trans("Files")); llxHeader('', $langs->trans("UserCard").' - '.$langs->trans("Files"));
if ($object->id) if ($object->id) {
{
/* /*
* Affichage onglets * Affichage onglets
*/ */
if (!empty($conf->notification->enabled)) $langs->load("mails"); if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = user_prepare_head($object); $head = user_prepare_head($object);
$form = new Form($db); $form = new Form($db);
@ -143,8 +153,7 @@ if ($object->id)
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $totalsize += $file['size'];
} }

View File

@ -38,8 +38,7 @@ $candisableperms = ($user->admin || $user->rights->user->user->supprimer);
$feature2 = 'user'; $feature2 = 'user';
// Advanced permissions // Advanced permissions
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$canreadperms = ($user->admin || $user->rights->user->group_advance->read); $canreadperms = ($user->admin || $user->rights->user->group_advance->read);
$caneditperms = ($user->admin || $user->rights->user->group_advance->write); $caneditperms = ($user->admin || $user->rights->user->group_advance->write);
$candisableperms = ($user->admin || $user->rights->user->group_advance->delete); $candisableperms = ($user->admin || $user->rights->user->group_advance->delete);
@ -62,8 +61,7 @@ $userid = GETPOST('user', 'int');
$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', $feature2); $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', $feature2);
// Users/Groups management only in master entity if transverse mode // Users/Groups management only in master entity if transverse mode
if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
{
accessforbidden(); accessforbidden();
} }
@ -87,29 +85,31 @@ $hookmanager->initHooks(array('groupcard', 'globalcard'));
$parameters = array('id' => $id, 'userid' => $userid, 'caneditperms' => $caneditperms); $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 $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
$backurlforlist = DOL_URL_ROOT.'/user/group/list.php'; $backurlforlist = DOL_URL_ROOT.'/user/group/list.php';
if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
else $backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); $backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
} }
} }
if ($cancel) if ($cancel) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
// Action remove group // Action remove group
if ($action == 'confirm_delete' && $confirm == "yes") if ($action == 'confirm_delete' && $confirm == "yes") {
{ if ($caneditperms) {
if ($caneditperms)
{
$object->fetch($id); $object->fetch($id);
$object->delete($user); $object->delete($user);
header("Location: ".DOL_URL_ROOT."/user/group/list.php?restore_lastsearch_values=1"); header("Location: ".DOL_URL_ROOT."/user/group/list.php?restore_lastsearch_values=1");
@ -121,10 +121,8 @@ if (empty($reshook)) {
} }
// Action add group // Action add group
if ($action == 'add') if ($action == 'add') {
{ if ($caneditperms) {
if ($caneditperms)
{
if (!GETPOST("nom", "nohtml")) { if (!GETPOST("nom", "nohtml")) {
setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
$action = "create"; // Go back to create page $action = "create"; // Go back to create page
@ -134,17 +132,21 @@ if (empty($reshook)) {
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
else $object->entity = $_POST["entity"]; $object->entity = 0;
} else {
$object->entity = $_POST["entity"];
}
$db->begin(); $db->begin();
$id = $object->create(); $id = $object->create();
if ($id > 0) if ($id > 0) {
{
$db->commit(); $db->commit();
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@ -164,22 +166,22 @@ if (empty($reshook)) {
} }
// Add/Remove user into group // Add/Remove user into group
if ($action == 'adduser' || $action == 'removeuser') if ($action == 'adduser' || $action == 'removeuser') {
{ if ($caneditperms) {
if ($caneditperms) if ($userid > 0) {
{
if ($userid > 0)
{
$object->fetch($id); $object->fetch($id);
$object->oldcopy = clone $object; $object->oldcopy = clone $object;
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($userid); $edituser->fetch($userid);
if ($action == 'adduser') $result = $edituser->SetInGroup($object->id, $object->entity); if ($action == 'adduser') {
if ($action == 'removeuser') $result = $edituser->RemoveFromGroup($object->id, $object->entity); $result = $edituser->SetInGroup($object->id, $object->entity);
}
if ($action == 'removeuser') {
$result = $edituser->RemoveFromGroup($object->id, $object->entity);
}
if ($result > 0) if ($result > 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
@ -193,10 +195,8 @@ if (empty($reshook)) {
} }
if ($action == 'update') if ($action == 'update') {
{ if ($caneditperms) {
if ($caneditperms)
{
$db->begin(); $db->begin();
$object->fetch($id); $object->fetch($id);
@ -208,15 +208,19 @@ if (empty($reshook)) {
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
else $object->entity = $_POST["entity"]; $object->entity = 0;
} else {
$object->entity = $_POST["entity"];
}
$ret = $object->update(); $ret = $object->update();
if ($ret >= 0 && !count($object->errors)) if ($ret >= 0 && !count($object->errors)) {
{
setEventMessages($langs->trans("GroupModified"), null, 'mesgs'); setEventMessages($langs->trans("GroupModified"), null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
@ -247,8 +251,7 @@ $fuserstatic = new User($db);
$form = new Form($db); $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
if ($action == 'create') if ($action == 'create') {
{
print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group'); print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group');
print dol_set_focus('#nom'); print dol_set_focus('#nom');
@ -263,10 +266,8 @@ if ($action == 'create')
print '<table class="border centpercent tableforfieldcreate">'; print '<table class="border centpercent tableforfieldcreate">';
// Multicompany // Multicompany
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc)) {
{ if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity)
{
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity); print "<td>".$mc->select_entities($conf->entity);
print "</td></tr>\n"; print "</td></tr>\n";
@ -292,17 +293,13 @@ if ($action == 'create')
print '</div>'; print '</div>';
print "</form>"; print "</form>";
} } else {
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Visu et edition */ /* Visu et edition */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
else { if ($id) {
if ($id)
{
$res = $object->fetch_optionals(); $res = $object->fetch_optionals();
$head = group_prepare_head($object); $head = group_prepare_head($object);
@ -311,8 +308,7 @@ else {
/* /*
* Confirmation suppression * Confirmation suppression
*/ */
if ($action == 'delete') if ($action == 'delete') {
{
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAGroup"), $langs->trans("ConfirmDeleteGroup", $object->name), "confirm_delete", '', 0, 1); print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAGroup"), $langs->trans("ConfirmDeleteGroup", $object->name), "confirm_delete", '', 0, 1);
} }
@ -320,8 +316,7 @@ else {
* Fiche en mode visu * Fiche en mode visu
*/ */
if ($action != 'edit') if ($action != 'edit') {
{
print dol_get_fiche_head($head, 'group', $title, -1, 'group'); print dol_get_fiche_head($head, 'group', $title, -1, 'group');
$linkback = '<a href="'.DOL_URL_ROOT.'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@ -335,20 +330,17 @@ else {
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
if (!empty($conf->mutlicompany->enabled)) if (!empty($conf->mutlicompany->enabled)) {
{
print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';
print '<td class="valeur">'.dol_escape_htmltag($object->name); print '<td class="valeur">'.dol_escape_htmltag($object->name);
if (empty($object->entity)) if (empty($object->entity)) {
{
print img_picto($langs->trans("GlobalGroup"), 'redstar'); print img_picto($langs->trans("GlobalGroup"), 'redstar');
} }
print "</td></tr>\n"; print "</td></tr>\n";
} }
// Multicompany // Multicompany
if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
{
$mc->getInfo($object->entity); $mc->getInfo($object->entity);
print "<tr>".'<td class="titlefield">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td class="titlefield">'.$langs->trans("Entity").'</td>';
print '<td class="valeur">'.dol_escape_htmltag($mc->label); print '<td class="valeur">'.dol_escape_htmltag($mc->label);
@ -381,15 +373,15 @@ else {
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $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 ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if ($caneditperms) if ($caneditperms) {
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&amp;token='.newToken().'">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&amp;token='.newToken().'">'.$langs->trans("Modify").'</a>';
} }
if ($candisableperms) if ($candisableperms) {
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$object->id.'&amp;token='.newToken().'">'.$langs->trans("DeleteGroup").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$object->id.'&amp;token='.newToken().'">'.$langs->trans("DeleteGroup").'</a>';
} }
@ -402,10 +394,8 @@ else {
// On selectionne les users qui ne sont pas deja dans le groupe // On selectionne les users qui ne sont pas deja dans le groupe
$exclude = array(); $exclude = array();
if (!empty($object->members)) if (!empty($object->members)) {
{ foreach ($object->members as $useringroup) {
foreach ($object->members as $useringroup)
{
$exclude[] = $useringroup->id; $exclude[] = $useringroup->id;
} }
} }
@ -415,10 +405,8 @@ else {
$reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook)) {
{ if ($caneditperms) {
if ($caneditperms)
{
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n"; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="adduser">'; print '<input type="hidden" name="action" value="adduser">';
@ -447,10 +435,8 @@ else {
print '<td class="liste_titre right" width="5">&nbsp;</td>'; print '<td class="liste_titre right" width="5">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
if (!empty($object->members)) if (!empty($object->members)) {
{ foreach ($object->members as $useringroup) {
foreach ($object->members as $useringroup)
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login');
@ -513,8 +499,7 @@ else {
* Fiche en mode edition * Fiche en mode edition
*/ */
if ($action == 'edit' && $caneditperms) if ($action == 'edit' && $caneditperms) {
{
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="updategroup" enctype="multipart/form-data">'; print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="updategroup" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -526,10 +511,8 @@ else {
print '<table class="border centpercent tableforfieldedit">'."\n"; print '<table class="border centpercent tableforfieldedit">'."\n";
// Multicompany // Multicompany
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc)) {
{ if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity)
{
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>'; print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($object->entity); print "<td>".$mc->select_entities($object->entity);
print "</td></tr>\n"; print "</td></tr>\n";

View File

@ -34,14 +34,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
$langs->loadLangs(array('companies', 'ldap', 'users', 'admin')); $langs->loadLangs(array('companies', 'ldap', 'users', 'admin'));
// Users/Groups management only in master entity if transverse mode // Users/Groups management only in master entity if transverse mode
if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
{
accessforbidden(); accessforbidden();
} }
$canreadperms = true; $canreadperms = true;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$canreadperms = ($user->admin || $user->rights->user->group_advance->read); $canreadperms = ($user->admin || $user->rights->user->group_advance->read);
} }
@ -49,7 +47,9 @@ $id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$object = new Usergroup($db); $object = new Usergroup($db);
$object->fetch($id); $object->fetch($id);
@ -60,13 +60,11 @@ $object->getrights();
* Actions * Actions
*/ */
if ($action == 'dolibarr2ldap') if ($action == 'dolibarr2ldap') {
{
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
// Get a gid number for objectclass PosixGroup // Get a gid number for objectclass PosixGroup
@ -80,8 +78,7 @@ if ($action == 'dolibarr2ldap')
$result = $ldap->update($dn, $info, $user, $olddn); $result = $ldap->update($dn, $info, $user, $olddn);
} }
if ($result >= 0) if ($result >= 0) {
{
setEventMessages($langs->trans("GroupSynchronized"), null, 'mesgs'); setEventMessages($langs->trans("GroupSynchronized"), null, 'mesgs');
} else { } else {
setEventMessages($ldap->error, $ldap->errors, 'errors'); setEventMessages($ldap->error, $ldap->errors, 'errors');
@ -111,12 +108,10 @@ print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
if (!empty($conf->mutlicompany->enabled)) if (!empty($conf->mutlicompany->enabled)) {
{
print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';
print '<td class="valeur">'.$object->name; print '<td class="valeur">'.$object->name;
if (!$object->entity) if (!$object->entity) {
{
print img_picto($langs->trans("GlobalGroup"), 'redstar'); print img_picto($langs->trans("GlobalGroup"), 'redstar');
} }
print "</td></tr>\n"; print "</td></tr>\n";
@ -153,14 +148,15 @@ print dol_get_fiche_end();
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
} }
print "</div>\n"; print "</div>\n";
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') print "<br>\n"; if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
print "<br>\n";
}
@ -177,8 +173,7 @@ print '</tr>';
// Lecture LDAP // Lecture LDAP
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info, 1); $dn = $object->_load_ldap_dn($info, 1);
$search = "(".$object->_load_ldap_dn($info, 2).")"; $search = "(".$object->_load_ldap_dn($info, 2).")";
@ -188,10 +183,8 @@ if ($result > 0)
//var_dump($records); //var_dump($records);
// Show tree // Show tree
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
{ if (!is_array($records)) {
if (!is_array($records))
{
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
} else { } else {
$result = show_ldap_content($records, 0, $records['count'], true); $result = show_ldap_content($records, 0, $records['count'], true);

View File

@ -28,15 +28,14 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{ if (!$user->rights->user->group_advance->read && !$user->admin) {
if (!$user->rights->user->group_advance->read && !$user->admin)
accessforbidden(); accessforbidden();
} }
}
// Users/Groups management only in master entity if transverse mode // Users/Groups management only in master entity if transverse mode
if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
{
accessforbidden(); accessforbidden();
} }
@ -50,8 +49,7 @@ $optioncss = GETPOST('optioncss', 'alpha');
// Defini si peux lire/modifier utilisateurs et permisssions // Defini si peux lire/modifier utilisateurs et permisssions
$caneditperms = ($user->admin || $user->rights->user->user->creer); $caneditperms = ($user->admin || $user->rights->user->user->creer);
// Advanced permissions // Advanced permissions
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$caneditperms = ($user->admin || $user->rights->user->group_advance->write); $caneditperms = ($user->admin || $user->rights->user->group_advance->write);
} }
@ -60,13 +58,19 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } if (empty($page) || $page == -1) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = "g.nom"; if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "g.nom";
}
if (!$sortorder) {
$sortorder = "ASC";
}
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array( $fieldstosearchall = array(
@ -79,21 +83,25 @@ $fieldstosearchall = array(
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
{
$search_label = ""; $search_label = "";
$search_date_creation = ""; $search_date_creation = "";
$search_date_update = ""; $search_date_update = "";
@ -113,20 +121,22 @@ $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, COUNT(DISTINCT
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) {
{
$sql .= " WHERE g.entity IS NOT NULL"; $sql .= " WHERE g.entity IS NOT NULL";
} else { } else {
$sql .= " WHERE g.entity IN (0,".$conf->entity.")"; $sql .= " WHERE g.entity IN (0,".$conf->entity.")";
} }
if (!empty($search_group)) natural_search(array("g.nom", "g.note"), $search_group); if (!empty($search_group)) {
if ($sall) $sql .= natural_search(array("g.nom", "g.note"), $sall); natural_search(array("g.nom", "g.note"), $search_group);
}
if ($sall) {
$sql .= natural_search(array("g.nom", "g.note"), $sall);
}
$sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec"; $sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec";
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$nbtotalofrecords = $num; $nbtotalofrecords = $num;
@ -134,18 +144,21 @@ if ($resql)
$i = 0; $i = 0;
$param = "&amp;search_group=".urlencode($search_group)."&amp;sall=".urlencode($sall); $param = "&amp;search_group=".urlencode($search_group)."&amp;sall=".urlencode($sall);
if ($optioncss != '') $param .= '&amp;optioncss='.$optioncss; if ($optioncss != '') {
$param .= '&amp;optioncss='.$optioncss;
}
$text = $langs->trans("ListOfGroups"); $text = $langs->trans("ListOfGroups");
$newcardbutton = ''; $newcardbutton = '';
if ($caneditperms) if ($caneditperms) {
{
$newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu='); $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu=');
} }
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@ -155,9 +168,10 @@ if ($resql)
print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'object_group', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'object_group', 0, $newcardbutton, '', $limit, 0, 0, 1);
if ($sall) if ($sall) {
{ foreach ($fieldstosearchall as $key => $val) {
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); $fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
} }
@ -172,8 +186,7 @@ if ($resql)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", $param, "", "", $sortfield, $sortorder);
//multicompany //multicompany
if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
{
print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], "g.entity", $param, "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], "g.entity", $param, "", '', $sortfield, $sortorder, 'center ');
} }
print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", $param, "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", $param, "", '', $sortfield, $sortorder, 'center ');
@ -184,8 +197,7 @@ if ($resql)
$grouptemp = new UserGroup($db); $grouptemp = new UserGroup($db);
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$grouptemp->id = $obj->rowid; $grouptemp->id = $obj->rowid;
@ -195,14 +207,12 @@ if ($resql)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
print $grouptemp->getNomUrl(1); print $grouptemp->getNomUrl(1);
if (!$obj->entity) if (!$obj->entity) {
{
print img_picto($langs->trans("GlobalGroup"), 'redstar'); print img_picto($langs->trans("GlobalGroup"), 'redstar');
} }
print "</td>"; print "</td>";
//multicompany //multicompany
if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
{
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print '<td class="center">'.$mc->label.'</td>'; print '<td class="center">'.$mc->label.'</td>';
} }

View File

@ -47,14 +47,15 @@ $canreadperms = ($user->admin || $user->rights->user->user->lire);
$caneditperms = ($user->admin || $user->rights->user->user->creer); $caneditperms = ($user->admin || $user->rights->user->user->creer);
// Advanced permissions // Advanced permissions
$advancedpermsactive = false; $advancedpermsactive = false;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$advancedpermsactive = true; $advancedpermsactive = true;
$canreadperms = ($user->admin || ($user->rights->user->group_advance->read && $user->rights->user->group_advance->readperms)); $canreadperms = ($user->admin || ($user->rights->user->group_advance->read && $user->rights->user->group_advance->readperms));
$caneditperms = ($user->admin || $user->rights->user->group_advance->write); $caneditperms = ($user->admin || $user->rights->user->group_advance->write);
} }
if (!$canreadperms) accessforbidden(); if (!$canreadperms) {
accessforbidden();
}
$object = new Usergroup($db); $object = new Usergroup($db);
$object->fetch($id); $object->fetch($id);
@ -71,7 +72,9 @@ $hookmanager->initHooks(array('groupperms', 'globalcard'));
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
if ($action == 'addrights' && $caneditperms) { if ($action == 'addrights' && $caneditperms) {
@ -110,8 +113,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("Permissions")); llxHeader('', $langs->trans("Permissions"));
if ($object->id > 0) if ($object->id > 0) {
{
/* /*
* Affichage onglets * Affichage onglets
*/ */
@ -127,32 +129,24 @@ if ($object->id > 0)
$db->begin(); $db->begin();
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir) {
{
$handle = @opendir(dol_osencode($dir)); $handle = @opendir(dol_osencode($dir));
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
{
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
{
$modName = substr($file, 0, dol_strlen($file) - 10); $modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName) if ($modName) {
{
include_once $dir.$file; include_once $dir.$file;
$objMod = new $modName($db); $objMod = new $modName($db);
// Load all lang files of module // Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles)) if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
{ foreach ($objMod->langfiles as $domain) {
foreach ($objMod->langfiles as $domain)
{
$langs->load($domain); $langs->load($domain);
} }
} }
// Load all permissions // Load all permissions
if ($objMod->rights_class) if ($objMod->rights_class) {
{
$ret = $objMod->insert_permissions(0, $entity); $ret = $objMod->insert_permissions(0, $entity);
$modules[$objMod->rights_class] = $objMod; $modules[$objMod->rights_class] = $objMod;
} }
@ -176,15 +170,14 @@ if ($object->id > 0)
dol_syslog("get user perms", LOG_DEBUG); dol_syslog("get user perms", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if (!isset($permsgroupbyentity[$obj->entity])) if (!isset($permsgroupbyentity[$obj->entity])) {
$permsgroupbyentity[$obj->entity] = array(); $permsgroupbyentity[$obj->entity] = array();
}
array_push($permsgroupbyentity[$obj->entity], $obj->id); array_push($permsgroupbyentity[$obj->entity], $obj->id);
$i++; $i++;
} }
@ -207,12 +200,10 @@ if ($object->id > 0)
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
if (!empty($conf->mutlicompany->enabled)) if (!empty($conf->mutlicompany->enabled)) {
{
print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';
print '<td colspan="2">'.$object->name.''; print '<td colspan="2">'.$object->name.'';
if (!$object->entity) if (!$object->entity) {
{
print img_picto($langs->trans("GlobalGroup"), 'redstar'); print img_picto($langs->trans("GlobalGroup"), 'redstar');
} }
print "</td></tr>\n"; print "</td></tr>\n";
@ -227,19 +218,22 @@ if ($object->id > 0)
print '</table><br>'; print '</table><br>';
if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); if ($user->admin) {
print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"));
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
print "\n"; print "\n";
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>'; print '<td>'.$langs->trans("Module").'</td>';
if ($caneditperms) if ($caneditperms) {
{
print '<td class="center nowrap">'; print '<td class="center nowrap">';
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>"; print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '/'; print '/';
@ -248,36 +242,36 @@ if ($object->id > 0)
} }
print '<td class="center" width="24">&nbsp;</td>'; print '<td class="center" width="24">&nbsp;</td>';
print '<td>'.$langs->trans("Permissions").'</td>'; print '<td>'.$langs->trans("Permissions").'</td>';
if ($user->admin) print '<td class="right">'.$langs->trans("ID").'</td>'; if ($user->admin) {
print '<td class="right">'.$langs->trans("ID").'</td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
$sql = "SELECT r.id, r.libelle as label, r.module"; $sql = "SELECT r.id, r.libelle as label, r.module";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql .= " AND r.entity = ".$entity; $sql .= " AND r.entity = ".$entity;
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
$sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable
}
$sql .= " ORDER BY r.module, r.id"; $sql .= " ORDER BY r.module, r.id";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$oldmod = ''; $oldmod = '';
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
if (empty($modules[$obj->module])) if (empty($modules[$obj->module])) {
{
$i++; $i++;
continue; continue;
} }
if ($oldmod <> $obj->module) if ($oldmod <> $obj->module) {
{
$oldmod = $obj->module; $oldmod = $obj->module;
// Break detected, we get objMod // Break detected, we get objMod
@ -290,8 +284,7 @@ if ($object->id > 0)
print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'"></a>'; print '<a name="'.$objMod->getName().'"></a>';
print '</td>'; print '</td>';
if ($caneditperms) if ($caneditperms) {
{
print '<td class="center nowrap">'; print '<td class="center nowrap">';
print '<a class="reposition" title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>"; print '<a class="reposition" title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>";
print '/'; print '/';
@ -303,7 +296,9 @@ if ($object->id > 0)
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
// Permission id // Permission id
if ($user->admin) print '<td class="right"></td>'; if ($user->admin) {
print '<td class="right"></td>';
}
print '</tr>'; print '</tr>';
} }
@ -316,13 +311,10 @@ if ($object->id > 0)
//print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName(); //print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName();
print '</td>'; print '</td>';
if (is_array($permsgroupbyentity[$entity])) if (is_array($permsgroupbyentity[$entity])) {
{ if (in_array($obj->id, $permsgroupbyentity[$entity])) {
if (in_array($obj->id, $permsgroupbyentity[$entity]))
{
// Own permission by group // Own permission by group
if ($caneditperms) if ($caneditperms) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">';
//print img_edit_remove($langs->trans("Remove")); //print img_edit_remove($langs->trans("Remove"));
print img_picto($langs->trans("Remove"), 'switch_on'); print img_picto($langs->trans("Remove"), 'switch_on');
@ -333,8 +325,7 @@ if ($object->id > 0)
print '</td>'; print '</td>';
} else { } else {
// Do not own permission // Do not own permission
if ($caneditperms) if ($caneditperms) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">';
//print img_edit_add($langs->trans("Add")); //print img_edit_add($langs->trans("Add"));
print img_picto($langs->trans("Add"), 'switch_off'); print img_picto($langs->trans("Add"), 'switch_off');
@ -344,8 +335,7 @@ if ($object->id > 0)
} }
} else { } else {
// Do not own permission // Do not own permission
if ($caneditperms) if ($caneditperms) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">';
//print img_edit_add($langs->trans("Add")); //print img_edit_add($langs->trans("Add"));
print img_picto($langs->trans("Add"), 'switch_off'); print img_picto($langs->trans("Add"), 'switch_off');
@ -358,7 +348,9 @@ if ($object->id > 0)
print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>'; print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>';
// Permission id // Permission id
if ($user->admin) print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>'; if ($user->admin) {
print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
@ -372,7 +364,9 @@ if ($object->id > 0)
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
print dol_get_fiche_end(); print dol_get_fiche_end();
} }

View File

@ -29,16 +29,18 @@
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
if (!$user->rights->user->user->lire && !$user->admin) if (!$user->rights->user->user->lire && !$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by page // Load translation files required by page
$langs->loadLangs(array('users', 'companies')); $langs->loadLangs(array('users', 'companies'));
// Security check (for external users) // Security check (for external users)
$socid = 0; $socid = 0;
if ($user->socid > 0) if ($user->socid > 0) {
$socid = $user->socid; $socid = $user->socid;
}
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_user = GETPOST('search_user', 'alpha'); $search_user = GETPOST('search_user', 'alpha');
@ -49,10 +51,11 @@ $mode = GETPOST("mode", 'alpha');
$userstatic = new User($db); $userstatic = new User($db);
$search_statut = GETPOST('search_statut', 'int'); $search_statut = GETPOST('search_statut', 'int');
if ($search_statut == '') $search_statut = '1'; if ($search_statut == '') {
$search_statut = '1';
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
{
$search_statut = ""; $search_statut = "";
} }
@ -79,8 +82,7 @@ llxHeader('', $langs->trans("ListOfUsers").' - '.$langs->trans("HierarchicView")
// Load hierarchy of users // Load hierarchy of users
$user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : ''); $user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : '');
if (!is_array($user_arbo) && $user_arbo < 0) if (!is_array($user_arbo) && $user_arbo < 0) {
{
setEventMessages($userstatic->error, $userstatic->errors, 'warnings'); setEventMessages($userstatic->error, $userstatic->errors, 'warnings');
} else { } else {
// Define fulltree array // Define fulltree array
@ -89,8 +91,7 @@ if (!is_array($user_arbo) && $user_arbo < 0)
// Define data (format for treeview) // Define data (format for treeview)
$data = array(); $data = array();
$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
foreach ($fulltree as $key => $val) foreach ($fulltree as $key => $val) {
{
$userstatic->id = $val['id']; $userstatic->id = $val['id'];
$userstatic->ref = $val['label']; $userstatic->ref = $val['label'];
$userstatic->login = $val['login']; $userstatic->login = $val['login'];
@ -108,10 +109,8 @@ if (!is_array($user_arbo) && $user_arbo < 0)
$entitystring = ''; $entitystring = '';
// TODO Set of entitystring should be done with a hook // TODO Set of entitystring should be done with a hook
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc)) {
{ if (empty($entity)) {
if (empty($entity))
{
$entitystring = $langs->trans("AllEntities"); $entitystring = $langs->trans("AllEntities");
} else { } else {
$mc->getInfo($entity); $mc->getInfo($entity);
@ -120,11 +119,9 @@ if (!is_array($user_arbo) && $user_arbo < 0)
} }
$li = $userstatic->getNomUrl(-1, '', 0, 1); $li = $userstatic->getNomUrl(-1, '', 0, 1);
if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity) if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity) {
{
$li .= img_picto($langs->trans("SuperAdministrator"), 'redstar'); $li .= img_picto($langs->trans("SuperAdministrator"), 'redstar');
} elseif ($userstatic->admin) } elseif ($userstatic->admin) {
{
$li .= img_picto($langs->trans("Administrator"), 'star'); $li .= img_picto($langs->trans("Administrator"), 'star');
} }
$li .= ' ('.$val['login'].($entitystring ? ' - '.$entitystring : '').')'; $li .= ' ('.$val['login'].($entitystring ? ' - '.$entitystring : '').')';
@ -155,7 +152,9 @@ if (!is_array($user_arbo) && $user_arbo < 0)
print load_fiche_titre($title, $morehtmlright.' '.$newcardbutton, 'user'); print load_fiche_titre($title, $morehtmlright.' '.$newcardbutton, 'user');
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
@ -188,8 +187,7 @@ if (!is_array($user_arbo) && $user_arbo < 0)
$nbofentries = (count($data) - 1); $nbofentries = (count($data) - 1);
if ($nbofentries > 0) if ($nbofentries > 0) {
{
print '<tr><td colspan="3">'; print '<tr><td colspan="3">';
tree_recur($data, $data[0], 0); tree_recur($data, $data[0], 0);
print '</td>'; print '</td>';

View File

@ -27,8 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userhome'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userhome'; // To manage different context of search
if (!$user->rights->user->user->lire && !$user->admin) if (!$user->rights->user->user->lire && !$user->admin) {
{
// Redirection vers la page de l'utilisateur // Redirection vers la page de l'utilisateur
header("Location: card.php?id=".$user->id); header("Location: card.php?id=".$user->id);
exit; exit;
@ -38,14 +37,15 @@ if (!$user->rights->user->user->lire && !$user->admin)
$langs->load("users"); $langs->load("users");
$canreadperms = true; $canreadperms = true;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$canreadperms = ($user->admin || $user->rights->user->group_advance->read); $canreadperms = ($user->admin || $user->rights->user->group_advance->read);
} }
// Security check (for external users) // Security check (for external users)
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$companystatic = new Societe($db); $companystatic = new Societe($db);
$fuserstatic = new User($db); $fuserstatic = new User($db);
@ -77,8 +77,7 @@ print '<tr><td>';
print $langs->trans("User").':</td><td><input class="flat inputsearch" type="text" name="search_user" size="18"></td></tr>'; print $langs->trans("User").':</td><td><input class="flat inputsearch" type="text" name="search_user" size="18"></td></tr>';
// Search Group // Search Group
if ($canreadperms) if ($canreadperms) {
{
print '<tr><td>'; print '<tr><td>';
print $langs->trans("Group").':</td><td><input class="flat inputsearch" type="text" name="search_group" size="18"></td></tr>'; print $langs->trans("Group").':</td><td><input class="flat inputsearch" type="text" name="search_group" size="18"></td></tr>';
} }
@ -115,13 +114,14 @@ if ($reshook > 0) {
} else { } else {
$sql .= " WHERE u.entity IN (".getEntity('user').")"; $sql .= " WHERE u.entity IN (".getEntity('user').")";
} }
if (!empty($socid)) $sql .= " AND u.fk_soc = ".$socid; if (!empty($socid)) {
$sql .= " AND u.fk_soc = ".$socid;
}
$sql .= $db->order("u.datec", "DESC"); $sql .= $db->order("u.datec", "DESC");
$sql .= $db->plimit($max); $sql .= $db->plimit($max);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -131,8 +131,7 @@ if ($resql)
print '</tr>'."\n"; print '</tr>'."\n";
$i = 0; $i = 0;
while ($i < $num && $i < $max) while ($i < $num && $i < $max) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$fuserstatic->id = $obj->rowid; $fuserstatic->id = $obj->rowid;
@ -153,34 +152,28 @@ if ($resql)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowraponall">'; print '<td class="nowraponall">';
print $fuserstatic->getNomUrl(-1); print $fuserstatic->getNomUrl(-1);
if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) {
{
print img_picto($langs->trans("SuperAdministrator"), 'redstar'); print img_picto($langs->trans("SuperAdministrator"), 'redstar');
} elseif ($obj->admin) } elseif ($obj->admin) {
{
print img_picto($langs->trans("Administrator"), 'star'); print img_picto($langs->trans("Administrator"), 'star');
} }
print "</td>"; print "</td>";
print '<td>'.$obj->login.'</td>'; print '<td>'.$obj->login.'</td>';
print "<td>"; print "<td>";
if ($obj->fk_soc) if ($obj->fk_soc) {
{
print $companystatic->getNomUrl(1); print $companystatic->getNomUrl(1);
} else { } else {
print $langs->trans("InternalUser"); print $langs->trans("InternalUser");
} }
if ($obj->ldap_sid) if ($obj->ldap_sid) {
{
print ' ('.$langs->trans("DomainUser").')'; print ' ('.$langs->trans("DomainUser").')';
} }
$entity = $obj->entity; $entity = $obj->entity;
$entitystring = ''; $entitystring = '';
// TODO Set of entitystring should be done with a hook // TODO Set of entitystring should be done with a hook
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc)) {
{ if (empty($entity)) {
if (empty($entity))
{
$entitystring = $langs->trans("AllEntities"); $entitystring = $langs->trans("AllEntities");
} else { } else {
$mc->getInfo($entity); $mc->getInfo($entity);
@ -210,14 +203,12 @@ if ($resql)
/* /*
* Last groups created * Last groups created
*/ */
if ($canreadperms) if ($canreadperms) {
{
$max = 5; $max = 5;
$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec"; $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec";
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) {
{
$sql .= " WHERE g.entity IS NOT NULL"; $sql .= " WHERE g.entity IS NOT NULL";
} else { } else {
$sql .= " WHERE g.entity IN (0,".$conf->entity.")"; $sql .= " WHERE g.entity IN (0,".$conf->entity.")";
@ -226,10 +217,11 @@ if ($canreadperms)
$sql .= $db->plimit($max); $sql .= $db->plimit($max);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$colspan = 1; $colspan = 1;
if (!empty($conf->multicompany->enabled)) $colspan++; if (!empty($conf->multicompany->enabled)) {
$colspan++;
}
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -241,8 +233,7 @@ if ($canreadperms)
$grouptemp = new UserGroup($db); $grouptemp = new UserGroup($db);
while ($i < $num && (!$max || $i < $max)) while ($i < $num && (!$max || $i < $max)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$grouptemp->id = $obj->rowid; $grouptemp->id = $obj->rowid;
@ -252,13 +243,11 @@ if ($canreadperms)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
print $grouptemp->getNomUrl(1); print $grouptemp->getNomUrl(1);
if (!$obj->entity) if (!$obj->entity) {
{
print img_picto($langs->trans("GlobalGroup"), 'redstar'); print img_picto($langs->trans("GlobalGroup"), 'redstar');
} }
print "</td>"; print "</td>";
if (!empty($conf->multicompany->enabled) && is_object($mc)) if (!empty($conf->multicompany->enabled) && is_object($mc)) {
{
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print '<td>'; print '<td>';
print $mc->label; print $mc->label;

View File

@ -33,22 +33,24 @@ $langs->load("users");
// Security check // Security check
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$object = new User($db); $object = new User($db);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{
$result = $object->fetch($id, $ref, '', 1); $result = $object->fetch($id, $ref, '', 1);
$object->getrights(); $object->getrights();
} }
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
// If user is not user that read and no permission to read other users, we stop // If user is not user that read and no permission to read other users, we stop
if (($object->id != $user->id) && (!$user->rights->user->user->lire)) if (($object->id != $user->id) && (!$user->rights->user->user->lire)) {
accessforbidden(); accessforbidden();
}

View File

@ -35,7 +35,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'use
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
@ -55,17 +57,16 @@ $hookmanager->initHooks(array('usercard', 'userldap', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{ if ($_GET["action"] == 'dolibarr2ldap') {
if ($_GET["action"] == 'dolibarr2ldap')
{
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info); $dn = $object->_load_ldap_dn($info);
$olddn = $dn; // We can say that old dn = dn as we force synchro $olddn = $dn; // We can say that old dn = dn as we force synchro
@ -109,20 +110,17 @@ print '<table class="border centpercent">';
// Login // Login
print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
if ($object->ldap_sid) if ($object->ldap_sid) {
{
print '<td class="warning">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>'; print '<td class="warning">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
} else { } else {
print '<td>'.$object->login.'</td>'; print '<td>'.$object->login.'</td>';
} }
print '</tr>'; print '</tr>';
if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") {
{
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$userSID = $ldap->getObjectSid($object->login); $userSID = $ldap->getObjectSid($object->login);
} }
print '<tr><td class="valigntop">'.$langs->trans("SID").'</td>'; print '<tr><td class="valigntop">'.$langs->trans("SID").'</td>';
@ -155,14 +153,15 @@ print dol_get_fiche_end();
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
} }
print "</div>\n"; print "</div>\n";
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') print "<br>\n"; if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
print "<br>\n";
}
@ -179,8 +178,7 @@ print '</tr>';
// Lecture LDAP // Lecture LDAP
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) if ($result > 0) {
{
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info, 1); $dn = $object->_load_ldap_dn($info, 1);
$search = "(".$object->_load_ldap_dn($info, 2).")"; $search = "(".$object->_load_ldap_dn($info, 2).")";
@ -190,10 +188,8 @@ if ($result > 0)
//print_r($records); //print_r($records);
// Affichage arbre // Affichage arbre
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
{ if (!is_array($records)) {
if (!is_array($records))
{
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
} else { } else {
$result = show_ldap_content($records, 0, $records['count'], true); $result = show_ldap_content($records, 0, $records['count'], true);

View File

@ -62,7 +62,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -78,15 +80,20 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
if (!$sortfield) $sortfield = "u.login"; if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "u.login";
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Initialize array of search criterias // Initialize array of search criterias
$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if (GETPOST('search_'.$key, 'alpha') !== '') {
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); $search[$key] = GETPOST('search_'.$key, 'alpha');
}
} }
$userstatic = new User($db); $userstatic = new User($db);
@ -104,8 +111,7 @@ $fieldstosearchall = array(
'u.email'=>"EMail", 'u.email'=>"EMail",
'u.note'=>"Note", 'u.note'=>"Note",
); );
if (!empty($conf->api->enabled)) if (!empty($conf->api->enabled)) {
{
$fieldstosearchall['u.api_key'] = "ApiKey"; $fieldstosearchall['u.api_key'] = "ApiKey";
} }
@ -158,8 +164,12 @@ $search_categ = GETPOST("search_categ", 'int');
$catid = GETPOST('catid', 'int'); $catid = GETPOST('catid', 'int');
// Default search // Default search
if ($search_statut == '') $search_statut = '1'; if ($search_statut == '') {
if ($mode == 'employee' && !GETPOSTISSET('search_employee')) $search_employee = 1; $search_statut = '1';
}
if ($mode == 'employee' && !GETPOSTISSET('search_employee')) {
$search_employee = 1;
}
// Define value to know what current user can do on users // Define value to know what current user can do on users
$permissiontoadd = (!empty($user->admin) || $user->rights->user->user->creer); $permissiontoadd = (!empty($user->admin) || $user->rights->user->user->creer);
@ -168,8 +178,7 @@ $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
$candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer); $candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer);
$canreadgroup = $canreaduser; $canreadgroup = $canreaduser;
$caneditgroup = $canedituser; $caneditgroup = $canedituser;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read); $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read);
$caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write);
} }
@ -183,21 +192,25 @@ $childids = $user->getAllChildIds(1);
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{
$search_user = ""; $search_user = "";
$search_login = ""; $search_login = "";
$search_lastname = ""; $search_lastname = "";
@ -227,17 +240,14 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Disable or Enable records // Disable or Enable records
if (!$error && ($massaction == 'disable' || $massaction == 'reactivate') && $permissiontoadd) if (!$error && ($massaction == 'disable' || $massaction == 'reactivate') && $permissiontoadd) {
{
$objecttmp = new User($db); $objecttmp = new User($db);
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$nbok = 0; $nbok = 0;
foreach ($toselect as $toselectid) foreach ($toselect as $toselectid) {
{
if ($toselectid == $user->id) { if ($toselectid == $user->id) {
setEventMessages($langs->trans($massaction == 0 ? 'CantDisableYourself' : 'CanEnableYourself'), null, 'errors'); setEventMessages($langs->trans($massaction == 0 ? 'CantDisableYourself' : 'CanEnableYourself'), null, 'errors');
$error++; $error++;
@ -259,7 +269,9 @@ if (empty($reshook))
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++; $error++;
break; break;
} else $nbok++; } else {
$nbok++;
}
} else { } else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++; $error++;
@ -275,10 +287,12 @@ if (empty($reshook))
} }
} }
if (!$error) if (!$error) {
{ if ($nbok > 1) {
if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); } else {
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
}
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
@ -327,7 +341,9 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
} }
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_user as cu ON u.rowid = cu.fk_user"; // We'll need this table joined to the select in order to filter by categ if (!empty($search_categ) || !empty($catid)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_user as cu ON u.rowid = cu.fk_user"; // We'll need this table joined to the select in order to filter by categ
}
// Add fields from hooks // Add fields from hooks
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printUserListWhere', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printUserListWhere', $parameters); // Note that $action and $object may have been modified by hook
@ -336,29 +352,67 @@ if ($reshook > 0) {
} else { } else {
$sql .= " WHERE u.entity IN (".getEntity('user').")"; $sql .= " WHERE u.entity IN (".getEntity('user').")";
} }
if ($socid > 0) $sql .= " AND u.fk_soc = ".$socid; if ($socid > 0) {
$sql .= " AND u.fk_soc = ".$socid;
}
//if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
if ($search_supervisor > 0) $sql .= " AND u.fk_user IN (".$db->sanitize($db->escape($search_supervisor)).")"; if ($search_supervisor > 0) {
if ($search_thirdparty != '') $sql .= natural_search(array('s.nom'), $search_thirdparty); $sql .= " AND u.fk_user IN (".$db->sanitize($db->escape($search_supervisor)).")";
if ($search_login != '') $sql .= natural_search("u.login", $search_login); }
if ($search_lastname != '') $sql .= natural_search("u.lastname", $search_lastname); if ($search_thirdparty != '') {
if ($search_firstname != '') $sql .= natural_search("u.firstname", $search_firstname); $sql .= natural_search(array('s.nom'), $search_thirdparty);
if ($search_gender != '' && $search_gender != '-1') $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman }
if ($search_login != '') {
$sql .= natural_search("u.login", $search_login);
}
if ($search_lastname != '') {
$sql .= natural_search("u.lastname", $search_lastname);
}
if ($search_firstname != '') {
$sql .= natural_search("u.firstname", $search_firstname);
}
if ($search_gender != '' && $search_gender != '-1') {
$sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman
}
if (is_numeric($search_employee) && $search_employee >= 0) { if (is_numeric($search_employee) && $search_employee >= 0) {
$sql .= ' AND u.employee = '.(int) $search_employee; $sql .= ' AND u.employee = '.(int) $search_employee;
} }
if ($search_accountancy_code != '') $sql .= natural_search("u.accountancy_code", $search_accountancy_code); if ($search_accountancy_code != '') {
if ($search_phonepro != '') $sql .= natural_search("u.office_phone", $search_phonepro); $sql .= natural_search("u.accountancy_code", $search_accountancy_code);
if ($search_phonemobile != '') $sql .= natural_search("u.user_mobile", $search_phonemobile); }
if ($search_email != '') $sql .= natural_search("u.email", $search_email); if ($search_phonepro != '') {
if ($search_api_key != '') $sql .= natural_search("u.api_key", $search_api_key); $sql .= natural_search("u.office_phone", $search_phonepro);
if ($search_statut != '' && $search_statut >= 0) $sql .= " AND u.statut IN (".$db->sanitize($db->escape($search_statut)).")"; }
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_phonemobile != '') {
if ($catid > 0) $sql .= " AND cu.fk_categorie = ".((int) $catid); $sql .= natural_search("u.user_mobile", $search_phonemobile);
if ($catid == -2) $sql .= " AND cu.fk_categorie IS NULL"; }
if ($search_categ > 0) $sql .= " AND cu.fk_categorie = ".$db->escape($search_categ); if ($search_email != '') {
if ($search_categ == -2) $sql .= " AND cu.fk_categorie IS NULL"; $sql .= natural_search("u.email", $search_email);
if ($mode == 'employee' && empty($user->rights->salaries->readall)) $sql .= " AND u.fk_user IN (".join(',', $childids).")"; }
if ($search_api_key != '') {
$sql .= natural_search("u.api_key", $search_api_key);
}
if ($search_statut != '' && $search_statut >= 0) {
$sql .= " AND u.statut IN (".$db->sanitize($db->escape($search_statut)).")";
}
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
if ($catid > 0) {
$sql .= " AND cu.fk_categorie = ".((int) $catid);
}
if ($catid == -2) {
$sql .= " AND cu.fk_categorie IS NULL";
}
if ($search_categ > 0) {
$sql .= " AND cu.fk_categorie = ".$db->escape($search_categ);
}
if ($search_categ == -2) {
$sql .= " AND cu.fk_categorie IS NULL";
}
if ($mode == 'employee' && empty($user->rights->salaries->readall)) {
$sql .= " AND u.fk_user IN (".join(',', $childids).")";
}
// Add where from extra fields // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks // Add where from hooks
@ -369,26 +423,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
{
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} else { } else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset); if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -397,8 +449,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
} }
// Direct jump if only one record found // Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$id = $obj->rowid; $id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id); header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id);
@ -411,40 +462,88 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
llxHeader('', $langs->trans("ListOfUsers"), $help_url); llxHeader('', $langs->trans("ListOfUsers"), $help_url);
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&amp;contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&amp;limit='.urlencode($limit); $param .= '&amp;contextpage='.urlencode($contextpage);
if ($sall != '') $param .= '&amp;sall='.urlencode($sall); }
if ($search_user != '') $param .= "&amp;search_user=".urlencode($search_user); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_login != '') $param .= "&amp;search_login=".urlencode($search_login); $param .= '&amp;limit='.urlencode($limit);
if ($search_lastname != '') $param .= "&amp;search_lastname=".urlencode($search_lastname); }
if ($search_firstname != '') $param .= "&amp;search_firstname=".urlencode($search_firstname); if ($sall != '') {
if ($search_gender != '') $param .= "&amp;search_gender=".urlencode($search_gender); $param .= '&amp;sall='.urlencode($sall);
if ($search_employee != '') $param .= "&amp;search_employee=".urlencode($search_employee); }
if ($search_accountancy_code != '') $param .= "&amp;search_accountancy_code=".urlencode($search_accountancy_code); if ($search_user != '') {
if ($search_phonepro != '') $param .= "&amp;search_phonepro=".urlencode($search_phonepro); $param .= "&amp;search_user=".urlencode($search_user);
if ($search_phonemobile != '') $param .= "&amp;search_phonemobile=".urlencode($search_phonemobile); }
if ($search_email != '') $param .= "&amp;search_email=".urlencode($search_email); if ($search_login != '') {
if ($search_api_key != '') $param .= "&amp;search_api_key=".urlencode($search_api_key); $param .= "&amp;search_login=".urlencode($search_login);
if ($search_supervisor > 0) $param .= "&amp;search_supervisor=".urlencode($search_supervisor); }
if ($search_statut != '') $param .= "&amp;search_statut=".urlencode($search_statut); if ($search_lastname != '') {
if ($optioncss != '') $param .= '&amp;optioncss='.urlencode($optioncss); $param .= "&amp;search_lastname=".urlencode($search_lastname);
if ($mode != '') $param .= '&amp;mode='.urlencode($mode); }
if ($search_categ > 0) $param .= "&amp;search_categ=".urlencode($search_categ); if ($search_firstname != '') {
$param .= "&amp;search_firstname=".urlencode($search_firstname);
}
if ($search_gender != '') {
$param .= "&amp;search_gender=".urlencode($search_gender);
}
if ($search_employee != '') {
$param .= "&amp;search_employee=".urlencode($search_employee);
}
if ($search_accountancy_code != '') {
$param .= "&amp;search_accountancy_code=".urlencode($search_accountancy_code);
}
if ($search_phonepro != '') {
$param .= "&amp;search_phonepro=".urlencode($search_phonepro);
}
if ($search_phonemobile != '') {
$param .= "&amp;search_phonemobile=".urlencode($search_phonemobile);
}
if ($search_email != '') {
$param .= "&amp;search_email=".urlencode($search_email);
}
if ($search_api_key != '') {
$param .= "&amp;search_api_key=".urlencode($search_api_key);
}
if ($search_supervisor > 0) {
$param .= "&amp;search_supervisor=".urlencode($search_supervisor);
}
if ($search_statut != '') {
$param .= "&amp;search_statut=".urlencode($search_statut);
}
if ($optioncss != '') {
$param .= '&amp;optioncss='.urlencode($optioncss);
}
if ($mode != '') {
$param .= '&amp;mode='.urlencode($mode);
}
if ($search_categ > 0) {
$param .= "&amp;search_categ=".urlencode($search_categ);
}
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available // List of mass actions available
$arrayofmassactions = array(); $arrayofmassactions = array();
if ($permissiontoadd) $arrayofmassactions['disable'] = $langs->trans("DisableUser"); if ($permissiontoadd) {
if ($permissiontoadd) $arrayofmassactions['reactivate'] = $langs->trans("Reactivate"); $arrayofmassactions['disable'] = $langs->trans("DisableUser");
if ($permissiontoadd) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); }
if ($permissiontoadd) {
$arrayofmassactions['reactivate'] = $langs->trans("Reactivate");
}
if ($permissiontoadd) {
$arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
}
//if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array(); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@ -453,7 +552,9 @@ print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$url = DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu='; $url = DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu=';
if (!empty($socid)) $url .= '&socid='.$socid; if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); $newcardbutton = dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
@ -471,8 +572,7 @@ $objecttmp = new User($db);
$trackid = 'use'.$object->id; $trackid = 'use'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if (!empty($catid)) if (!empty($catid)) {
{
print "<div id='ways'>"; print "<div id='ways'>";
$c = new Categorie($db); $c = new Categorie($db);
$ways = $c->print_all_ways(' &gt; ', 'user/list.php'); $ways = $c->print_all_ways(' &gt; ', 'user/list.php');
@ -480,9 +580,10 @@ if (!empty($catid))
print "</div><br>"; print "</div><br>";
} }
if ($search_all) if ($search_all) {
{ foreach ($fieldstosearchall as $key => $val) {
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); $fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
} }
@ -492,8 +593,7 @@ $moreforfilter = '';
$moreforfilter.= '</div>';*/ $moreforfilter.= '</div>';*/
// Filter on categories // Filter on categories
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
{
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('Categories').': '; $moreforfilter .= $langs->trans('Categories').': ';
$moreforfilter .= $formother->select_categories(Categorie::TYPE_USER, $search_categ, 'search_categ', 1); $moreforfilter .= $formother->select_categories(Categorie::TYPE_USER, $search_categ, 'search_categ', 1);
@ -502,11 +602,13 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) {
else $moreforfilter = $hookmanager->resPrint; $moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter)) if (!empty($moreforfilter)) {
{
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
print '</div>'; print '</div>';
@ -522,76 +624,60 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// Fields title search // Fields title search
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['u.login']['checked'])) if (!empty($arrayfields['u.login']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
} }
if (!empty($arrayfields['u.lastname']['checked'])) if (!empty($arrayfields['u.lastname']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_lastname" class="maxwidth50" value="'.$search_lastname.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_lastname" class="maxwidth50" value="'.$search_lastname.'"></td>';
} }
if (!empty($arrayfields['u.firstname']['checked'])) if (!empty($arrayfields['u.firstname']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_firstname" class="maxwidth50" value="'.$search_firstname.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_firstname" class="maxwidth50" value="'.$search_firstname.'"></td>';
} }
if (!empty($arrayfields['u.gender']['checked'])) if (!empty($arrayfields['u.gender']['checked'])) {
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
print $form->selectarray('search_gender', $arraygender, $search_gender, 1); print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['u.employee']['checked'])) if (!empty($arrayfields['u.employee']['checked'])) {
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->selectyesno('search_employee', $search_employee, 1, false, 1); print $form->selectyesno('search_employee', $search_employee, 1, false, 1);
print '</td>'; print '</td>';
} }
// Supervisor // Supervisor
if (!empty($arrayfields['u.fk_user']['checked'])) if (!empty($arrayfields['u.fk_user']['checked'])) {
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200');
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['u.accountancy_code']['checked'])) if (!empty($arrayfields['u.accountancy_code']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_accountancy_code" class="maxwidth50" value="'.$search_accountancy_code.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_accountancy_code" class="maxwidth50" value="'.$search_accountancy_code.'"></td>';
} }
if (!empty($arrayfields['u.office_phone']['checked'])) if (!empty($arrayfields['u.office_phone']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_phonepro" class="maxwidth75" value="'.$search_phonepro.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_phonepro" class="maxwidth75" value="'.$search_phonepro.'"></td>';
} }
if (!empty($arrayfields['u.user_mobile']['checked'])) if (!empty($arrayfields['u.user_mobile']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_phonemobile" class="maxwidth75" value="'.$search_phonemobile.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_phonemobile" class="maxwidth75" value="'.$search_phonemobile.'"></td>';
} }
if (!empty($arrayfields['u.email']['checked'])) if (!empty($arrayfields['u.email']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_email" class="maxwidth75" value="'.$search_email.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_email" class="maxwidth75" value="'.$search_email.'"></td>';
} }
if (!empty($arrayfields['u.api_key']['checked'])) if (!empty($arrayfields['u.api_key']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_api_key" class="maxwidth50" value="'.$search_api_key.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_api_key" class="maxwidth50" value="'.$search_api_key.'"></td>';
} }
if (!empty($arrayfields['u.fk_soc']['checked'])) if (!empty($arrayfields['u.fk_soc']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_thirdparty" class="maxwidth75" value="'.$search_thirdparty.'"></td>'; print '<td class="liste_titre"><input type="text" name="search_thirdparty" class="maxwidth75" value="'.$search_thirdparty.'"></td>';
} }
if (!empty($arrayfields['u.entity']['checked'])) if (!empty($arrayfields['u.entity']['checked'])) {
{
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
if (!empty($arrayfields['u.salary']['checked'])) if (!empty($arrayfields['u.salary']['checked'])) {
{
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
if (!empty($arrayfields['u.datelastlogin']['checked'])) if (!empty($arrayfields['u.datelastlogin']['checked'])) {
{
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
if (!empty($arrayfields['u.datepreviouslogin']['checked'])) if (!empty($arrayfields['u.datepreviouslogin']['checked'])) {
{
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
// Extra fields // Extra fields
@ -600,20 +686,17 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
$parameters = array('arrayfields'=>$arrayfields); $parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (!empty($arrayfields['u.datec']['checked'])) if (!empty($arrayfields['u.datec']['checked'])) {
{
// Date creation // Date creation
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['u.tms']['checked'])) if (!empty($arrayfields['u.tms']['checked'])) {
{
// Date modification // Date modification
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['u.statut']['checked'])) if (!empty($arrayfields['u.statut']['checked'])) {
{
// Status // Status
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut); print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut);
@ -628,31 +711,69 @@ print '</tr>'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre("Login", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.login']['checked'])) {
if (!empty($arrayfields['u.lastname']['checked'])) print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Login", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['u.firstname']['checked'])) print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder); }
if (!empty($arrayfields['u.gender']['checked'])) print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.lastname']['checked'])) {
if (!empty($arrayfields['u.employee']['checked'])) print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['u.fk_user']['checked'])) print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder); }
if (!empty($arrayfields['u.accountancy_code']['checked'])) print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.firstname']['checked'])) {
if (!empty($arrayfields['u.office_phone']['checked'])) print_liste_field_titre("PhonePro", $_SERVER['PHP_SELF'], "u.office_phone", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['u.user_mobile']['checked'])) print_liste_field_titre("PhoneMobile", $_SERVER['PHP_SELF'], "u.user_mobile", $param, "", "", $sortfield, $sortorder); }
if (!empty($arrayfields['u.email']['checked'])) print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.gender']['checked'])) {
if (!empty($arrayfields['u.api_key']['checked'])) print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['u.fk_soc']['checked'])) print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder); }
if (!empty($arrayfields['u.entity']['checked'])) print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.employee']['checked'])) {
if (!empty($arrayfields['u.salary']['checked'])) print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right '); print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['u.datelastlogin']['checked'])) print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center '); }
if (!empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['u.fk_user']['checked'])) {
print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.accountancy_code']['checked'])) {
print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.office_phone']['checked'])) {
print_liste_field_titre("PhonePro", $_SERVER['PHP_SELF'], "u.office_phone", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.user_mobile']['checked'])) {
print_liste_field_titre("PhoneMobile", $_SERVER['PHP_SELF'], "u.user_mobile", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.email']['checked'])) {
print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.api_key']['checked'])) {
print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.fk_soc']['checked'])) {
print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.entity']['checked'])) {
print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['u.salary']['checked'])) {
print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['u.datelastlogin']['checked'])) {
print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['u.datepreviouslogin']['checked'])) {
print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center ');
}
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields // Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (!empty($arrayfields['u.datec']['checked'])) {
if (!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "u.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center '); }
if (!empty($arrayfields['u.tms']['checked'])) {
print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "u.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['u.statut']['checked'])) {
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Action column // Action column
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
print '</tr>'."\n"; print '</tr>'."\n";
@ -660,11 +781,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line // Detect if we need a fetch on each output line
$needToFetchEachLine = 0; $needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) if (preg_match('/\$object/', $val)) {
{ $needToFetchEachLine++; // There is at least one compute field that use $object
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object }
} }
} }
@ -674,10 +795,11 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
$i = 0; $i = 0;
$totalarray = array(); $totalarray = array();
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
while ($i < ($limit ? min($num, $limit) : $num)) while ($i < ($limit ? min($num, $limit) : $num)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object // Store properties in $object
$object->setVarsFromFetchObj($obj); $object->setVarsFromFetchObj($obj);
@ -700,50 +822,53 @@ while ($i < ($limit ? min($num, $limit) : $num))
$li = $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); $li = $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (!empty($arrayfields['u.login']['checked'])) if (!empty($arrayfields['u.login']['checked'])) {
{
print '<td class="nowraponall">'; print '<td class="nowraponall">';
print $li; print $li;
if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) {
{
print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"');
} elseif ($obj->admin) } elseif ($obj->admin) {
{
print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"');
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.lastname']['checked'])) }
{ if (!empty($arrayfields['u.lastname']['checked'])) {
print '<td class="tdoverflowmax150">'.$obj->lastname.'</td>'; print '<td class="tdoverflowmax150">'.$obj->lastname.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.firstname']['checked'])) }
{ if (!empty($arrayfields['u.firstname']['checked'])) {
print '<td class="tdoverflowmax150">'.$obj->firstname.'</td>'; print '<td class="tdoverflowmax150">'.$obj->firstname.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.gender']['checked'])) }
{ if (!empty($arrayfields['u.gender']['checked'])) {
print '<td>'; print '<td>';
if ($obj->gender) print $langs->trans("Gender".$obj->gender); if ($obj->gender) {
print '</td>'; print $langs->trans("Gender".$obj->gender);
if (!$i) $totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.employee']['checked'])) print '</td>';
{ if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['u.employee']['checked'])) {
print '<td>'.yn($obj->employee).'</td>'; print '<td>'.yn($obj->employee).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Supervisor // Supervisor
if (!empty($arrayfields['u.fk_user']['checked'])) if (!empty($arrayfields['u.fk_user']['checked'])) {
{
// Resp // Resp
print '<td class="nowrap">'; print '<td class="nowrap">';
if ($obj->login2) if ($obj->login2) {
{
$user2->id = $obj->id2; $user2->id = $obj->id2;
$user2->login = $obj->login2; $user2->login = $obj->login2;
$user2->lastname = $obj->lastname2; $user2->lastname = $obj->lastname2;
@ -757,97 +882,103 @@ while ($i < ($limit ? min($num, $limit) : $num))
$user2->socid = $obj->fk_soc2; $user2->socid = $obj->fk_soc2;
$user2->statut = $obj->statut2; $user2->statut = $obj->statut2;
print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1); print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1);
if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2) if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2) {
{
print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"');
} elseif ($obj->admin2) } elseif ($obj->admin2) {
{
print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"');
} }
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
if (!empty($arrayfields['u.accountancy_code']['checked'])) if (!empty($arrayfields['u.accountancy_code']['checked'])) {
{
print '<td>'.$obj->accountancy_code.'</td>'; print '<td>'.$obj->accountancy_code.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.office_phone']['checked'])) }
{ if (!empty($arrayfields['u.office_phone']['checked'])) {
print "<td>".dol_print_phone($obj->office_phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n"; print "<td>".dol_print_phone($obj->office_phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.user_mobile']['checked'])) }
{ if (!empty($arrayfields['u.user_mobile']['checked'])) {
print "<td>".dol_print_phone($obj->user_mobile, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'mobile')."</td>\n"; print "<td>".dol_print_phone($obj->user_mobile, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'mobile')."</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.email']['checked'])) }
{ if (!empty($arrayfields['u.email']['checked'])) {
print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 0, 0, 1)."</td>\n"; print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 0, 0, 1)."</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.api_key']['checked'])) }
{ if (!empty($arrayfields['u.api_key']['checked'])) {
print '<td>'.$obj->api_key.'</td>'; print '<td>'.$obj->api_key.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.fk_soc']['checked'])) }
{ if (!empty($arrayfields['u.fk_soc']['checked'])) {
print "<td>"; print "<td>";
if ($obj->fk_soc) if ($obj->fk_soc) {
{
$companystatic->id = $obj->fk_soc; $companystatic->id = $obj->fk_soc;
$companystatic->name = $obj->name; $companystatic->name = $obj->name;
$companystatic->canvas = $obj->canvas; $companystatic->canvas = $obj->canvas;
print $companystatic->getNomUrl(1); print $companystatic->getNomUrl(1);
} elseif ($obj->ldap_sid) } elseif ($obj->ldap_sid) {
{
print $langs->trans("DomainUser"); print $langs->trans("DomainUser");
} else { } else {
print $langs->trans("InternalUser"); print $langs->trans("InternalUser");
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Multicompany enabled // Multicompany enabled
if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
{ if (!empty($arrayfields['u.entity']['checked'])) {
if (!empty($arrayfields['u.entity']['checked']))
{
print '<td>'; print '<td>';
if (!$obj->entity) if (!$obj->entity) {
{
print $langs->trans("AllEntities"); print $langs->trans("AllEntities");
} else { } else {
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print $mc->label; print $mc->label;
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
} }
// Salary // Salary
if (!empty($arrayfields['u.salary']['checked'])) if (!empty($arrayfields['u.salary']['checked'])) {
{
print '<td class="nowraponall right">'.($obj->salary ? price($obj->salary) : '').'</td>'; print '<td class="nowraponall right">'.($obj->salary ? price($obj->salary) : '').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Date last login // Date last login
if (!empty($arrayfields['u.datelastlogin']['checked'])) if (!empty($arrayfields['u.datelastlogin']['checked'])) {
{
print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datelastlogin), "dayhour").'</td>'; print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datelastlogin), "dayhour").'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Date previous login // Date previous login
if (!empty($arrayfields['u.datepreviouslogin']['checked'])) if (!empty($arrayfields['u.datepreviouslogin']['checked'])) {
{
print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datepreviouslogin), "dayhour").'</td>'; print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datepreviouslogin), "dayhour").'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Extra fields // Extra fields
@ -857,38 +988,44 @@ while ($i < ($limit ? min($num, $limit) : $num))
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation
if (!empty($arrayfields['u.datec']['checked'])) if (!empty($arrayfields['u.datec']['checked'])) {
{
print '<td class="center">'; print '<td class="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Date modification // Date modification
if (!empty($arrayfields['u.tms']['checked'])) if (!empty($arrayfields['u.tms']['checked'])) {
{
print '<td class="center">'; print '<td class="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Status // Status
if (!empty($arrayfields['u.statut']['checked'])) if (!empty($arrayfields['u.statut']['checked'])) {
{
$userstatic->statut = $obj->statut; $userstatic->statut = $obj->statut;
print '<td class="center">'.$userstatic->getLibStatut(5).'</td>'; print '<td class="center">'.$userstatic->getLibStatut(5).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Action column // Action column
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0; $selected = 0;
if (in_array($object->id, $arrayofselected)) $selected = 1; if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n"; print '</tr>'."\n";
@ -899,10 +1036,13 @@ while ($i < ($limit ? min($num, $limit) : $num))
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found // If no record found
if ($num == 0) if ($num == 0) {
{
$colspan = 1; $colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
} }

View File

@ -24,17 +24,24 @@
*/ */
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREMENU')) {
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); }
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // We need company to get correct logo onto home page //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // We need company to get correct logo onto home page
if (!defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) define('EVEN_IF_ONLY_LOGIN_ALLOWED', '1'); if (!defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) {
define('EVEN_IF_ONLY_LOGIN_ALLOWED', '1');
}
require_once '../main.inc.php'; require_once '../main.inc.php';
// This can happen only with a bookmark or forged url call. // This can happen only with a bookmark or forged url call.
if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser' || $_SESSION["dol_authmode"] == 'http')) if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser' || $_SESSION["dol_authmode"] == 'http')) {
{
unset($_SESSION["dol_login"]); unset($_SESSION["dol_login"]);
die("Applicative disconnection should be useless when connection was made in mode ".$_SESSION["dol_authmode"]); die("Applicative disconnection should be useless when connection was made in mode ".$_SESSION["dol_authmode"]);
} }
@ -43,7 +50,9 @@ global $conf, $langs, $user;
// Call trigger // Call trigger
$result = $user->call_trigger('USER_LOGOUT', $user); $result = $user->call_trigger('USER_LOGOUT', $user);
if ($result < 0) $error++; if ($result < 0) {
$error++;
}
// End call triggers // End call triggers
// Hooks on logout // Hooks on logout
@ -51,26 +60,41 @@ $action = '';
$hookmanager->initHooks(array('logout')); $hookmanager->initHooks(array('logout'));
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('afterLogout', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('afterLogout', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) { $error++; } if ($reshook < 0) {
$error++;
}
// Define url to go after disconnect // Define url to go after disconnect
$urlfrom = empty($_SESSION["urlfrom"]) ? '' : $_SESSION["urlfrom"]; $urlfrom = empty($_SESSION["urlfrom"]) ? '' : $_SESSION["urlfrom"];
// Define url to go // Define url to go
$url = DOL_URL_ROOT."/index.php"; // By default go to login page $url = DOL_URL_ROOT."/index.php"; // By default go to login page
if ($urlfrom) $url = DOL_URL_ROOT.$urlfrom; if ($urlfrom) {
if (!empty($conf->global->MAIN_LOGOUT_GOTO_URL)) $url = $conf->global->MAIN_LOGOUT_GOTO_URL; $url = DOL_URL_ROOT.$urlfrom;
}
if (!empty($conf->global->MAIN_LOGOUT_GOTO_URL)) {
$url = $conf->global->MAIN_LOGOUT_GOTO_URL;
}
if (GETPOST('dol_hide_topmenu')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_topmenu=1'; if (GETPOST('dol_hide_topmenu')) {
if (GETPOST('dol_hide_leftmenu')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_leftmenu=1'; $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_topmenu=1';
if (GETPOST('dol_optimize_smallscreen')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_optimize_smallscreen=1'; }
if (GETPOST('dol_no_mouse_hover')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_no_mouse_hover=1'; if (GETPOST('dol_hide_leftmenu')) {
if (GETPOST('dol_use_jmobile')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_use_jmobile=1'; $url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_hide_leftmenu=1';
}
if (GETPOST('dol_optimize_smallscreen')) {
$url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_optimize_smallscreen=1';
}
if (GETPOST('dol_no_mouse_hover')) {
$url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_no_mouse_hover=1';
}
if (GETPOST('dol_use_jmobile')) {
$url .= (preg_match('/\?/', $url) ? '&' : '?').'dol_use_jmobile=1';
}
// Destroy session // Destroy session
dol_syslog("End of session ".session_id()); dol_syslog("End of session ".session_id());
if (session_status() === PHP_SESSION_ACTIVE) if (session_status() === PHP_SESSION_ACTIVE) {
{
session_destroy(); session_destroy();
} }
@ -80,5 +104,7 @@ unset($_SESSION['dol_login']);
unset($_SESSION['dol_entity']); unset($_SESSION['dol_entity']);
unset($_SESSION['urlfrom']); unset($_SESSION['urlfrom']);
if (GETPOST('noredirect')) return; if (GETPOST('noredirect')) {
return;
}
header("Location: ".$url); // Default behaviour is redirect to index.php page header("Location: ".$url); // Default behaviour is redirect to index.php page

View File

@ -39,11 +39,15 @@ $object->fetch($id, '', '', 1);
$object->getrights(); $object->getrights();
// If user is not user read and no permission to read other users, we stop // If user is not user read and no permission to read other users, we stop
if (($object->id != $user->id) && (!$user->rights->user->user->lire)) accessforbidden(); if (($object->id != $user->id) && (!$user->rights->user->user->lire)) {
accessforbidden();
}
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
@ -58,7 +62,9 @@ $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) { if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) {
@ -83,8 +89,7 @@ llxHeader();
$form = new Form($db); $form = new Form($db);
if ($id) if ($id) {
{
$head = user_prepare_head($object); $head = user_prepare_head($object);
$title = $langs->trans("User"); $title = $langs->trans("User");
@ -114,8 +119,7 @@ if ($id)
// Note // Note
print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>'; print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>';
print '<td class="'.($editenabled ? '' : 'sensiblehtmlcontent').'">'; print '<td class="'.($editenabled ? '' : 'sensiblehtmlcontent').'">';
if ($editenabled) if ($editenabled) {
{
print "<input type=\"hidden\" name=\"action\" value=\"update\">"; print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">"; print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">";
// Editeur wysiwyg // Editeur wysiwyg
@ -132,8 +136,7 @@ if ($id)
print dol_get_fiche_end(); print dol_get_fiche_end();
if ($action == 'edit') if ($action == 'edit') {
{
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button button-save" name="update" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button button-save" name="update" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
@ -148,8 +151,7 @@ if ($id)
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->user->user->creer && $action != 'edit') if ($user->rights->user->user->creer && $action != 'edit') {
{
print "<a class=\"butAction\" href=\"note.php?id=".$object->id."&amp;action=edit\">".$langs->trans('Modify')."</a>"; print "<a class=\"butAction\" href=\"note.php?id=".$object->id."&amp;action=edit\">".$langs->trans('Modify')."</a>";
} }

View File

@ -39,16 +39,24 @@ $action = GETPOST('action', 'aZ09');
$actionid = GETPOST('actionid'); $actionid = GETPOST('actionid');
// Security check // Security check
if ($user->socid) $id = $user->socid; if ($user->socid) {
$id = $user->socid;
}
$result = restrictedArea($user, 'societe', '', ''); $result = restrictedArea($user, 'societe', '', '');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "n.daten"; $sortorder = "DESC";
if (empty($page) || $page == -1) { $page = 0; } }
if (!$sortfield) {
$sortfield = "n.daten";
}
if (empty($page) || $page == -1) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -61,29 +69,24 @@ $now = dol_now();
*/ */
// Add a notification // Add a notification
if ($action == 'add') if ($action == 'add') {
{
$error = 0; $error = 0;
if ($actionid <= 0) if ($actionid <= 0) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
$sql .= " WHERE fk_user=".$id." AND fk_action=".$actionid; $sql .= " WHERE fk_user=".$id." AND fk_action=".$actionid;
if ($db->query($sql)) if ($db->query($sql)) {
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_action)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_action)";
$sql .= " VALUES ('".$db->idate($now)."',".$id.",".$actionid.")"; $sql .= " VALUES ('".$db->idate($now)."',".$id.",".$actionid.")";
if (!$db->query($sql)) if (!$db->query($sql)) {
{
$error++; $error++;
dol_print_error($db); dol_print_error($db);
} }
@ -91,8 +94,7 @@ if ($action == 'add')
dol_print_error($db); dol_print_error($db);
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
@ -101,8 +103,7 @@ if ($action == 'add')
} }
// Remove a notification // Remove a notification
if ($action == 'delete') if ($action == 'delete') {
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int"); $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int");
$db->query($sql); $db->query($sql);
} }
@ -120,13 +121,14 @@ $result = $object->fetch($id, '', '', 1);
$object->getrights(); $object->getrights();
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification"); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notification"); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name.' - '.$langs->trans("Notification");
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
if ($result > 0) if ($result > 0) {
{
$langs->load("other"); $langs->load("other");
$head = user_prepare_head($object); $head = user_prepare_head($object);
@ -144,8 +146,7 @@ if ($result > 0)
// Login // Login
print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
if (!empty($object->ldap_sid) && $object->statut == 0) if (!empty($object->ldap_sid) && $object->statut == 0) {
{
print '<td class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>'; print '<td class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
} else { } else {
print '<td>'.$object->login.'</td>'; print '<td>'.$object->login.'</td>';
@ -203,23 +204,20 @@ if ($result > 0)
// $listofemails=$object->thirdparty_and_contact_email_array(); // $listofemails=$object->thirdparty_and_contact_email_array();
if ($object->email) if ($object->email) {
{
$actions = array(); $actions = array();
// Load array of available notifications // Load array of available notifications
$notificationtrigger = new InterfaceNotification($db); $notificationtrigger = new InterfaceNotification($db);
$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
foreach ($listofnotifiedevents as $notifiedevent) foreach ($listofnotifiedevents as $notifiedevent) {
{
$label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']); $label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']);
$actions[$notifiedevent['rowid']] = $label; $actions[$notifiedevent['rowid']] = $label;
} }
print '<tr class="oddeven nohover"><td>'; print '<tr class="oddeven nohover"><td>';
print $object->getNomUrl(1); print $object->getNomUrl(1);
if (isValidEmail($object->email)) if (isValidEmail($object->email)) {
{
print ' &lt;'.$object->email.'&gt;'; print ' &lt;'.$object->email.'&gt;';
} else { } else {
$langs->load("errors"); $langs->load("errors");
@ -258,8 +256,7 @@ if ($result > 0)
$sql .= " AND c.rowid = ".$object->id; $sql .= " AND c.rowid = ".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -280,24 +277,20 @@ if ($result > 0)
$langs->load("errors"); $langs->load("errors");
$langs->load("other"); $langs->load("other");
if ($num) if ($num) {
{
$i = 0; $i = 0;
$userstatic = new user($db); $userstatic = new user($db);
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$userstatic->id = $obj->userid; $userstatic->id = $obj->userid;
$userstatic->lastname = $obj->lastname; $userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname; $userstatic->firstname = $obj->firstname;
print '<tr class="oddeven"><td>'.$userstatic->getNomUrl(1); print '<tr class="oddeven"><td>'.$userstatic->getNomUrl(1);
if ($obj->type == 'email') if ($obj->type == 'email') {
{ if (isValidEmail($obj->email)) {
if (isValidEmail($obj->email))
{
print ' &lt;'.$obj->email.'&gt;'; print ' &lt;'.$obj->email.'&gt;';
} else { } else {
$langs->load("errors"); $langs->load("errors");
@ -310,8 +303,12 @@ if ($result > 0)
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label; print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') {
if ($obj->type == 'sms') print $langs->trans("SMS"); print $langs->trans("Email");
}
if ($obj->type == 'sms') {
print $langs->trans("SMS");
}
print '</td>'; print '</td>';
print '<td class="right"><a href="card.php?id='.$id.'&amp;action=delete&amp;token='.newToken().'&amp;actid='.$obj->rowid.'">'.img_delete().'</a></td>'; print '<td class="right"><a href="card.php?id='.$id.'&amp;action=delete&amp;token='.newToken().'&amp;actid='.$obj->rowid.'">'.img_delete().'</a></td>';
print '</tr>'; print '</tr>';
@ -387,12 +384,10 @@ if ($result > 0)
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -401,19 +396,24 @@ if ($result > 0)
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$param = '&id='.$object->id; $param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; $param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@ -434,19 +434,16 @@ if ($result > 0)
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right ');
print '</tr>'; print '</tr>';
if ($num) if ($num) {
{
$i = 0; $i = 0;
$userstatic = new User($db); $userstatic = new User($db);
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($obj->id > 0) if ($obj->id > 0) {
{
$userstatic->id = $obj->id; $userstatic->id = $obj->id;
$userstatic->lastname = $obj->lastname; $userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname; $userstatic->firstname = $obj->firstname;
@ -461,8 +458,12 @@ if ($result > 0)
print $label; print $label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') {
if ($obj->type == 'sms') print $langs->trans("Sms"); print $langs->trans("Email");
}
if ($obj->type == 'sms') {
print $langs->trans("Sms");
}
print '</td>'; print '</td>';
// TODO Add link to object here for other types // TODO Add link to object here for other types
/*print '<td>'; /*print '<td>';
@ -486,7 +487,9 @@ if ($result > 0)
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} else dol_print_error('', 'RecordNotFound'); } else {
dol_print_error('', 'RecordNotFound');
}
// End of page // End of page
llxFooter(); llxFooter();

View File

@ -38,8 +38,7 @@ $id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userihm'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userihm'; // To manage different context of search
if ($id) if ($id) {
{
// $user est le user qui edite, $id est l'id de l'utilisateur edite // $user est le user qui edite, $id est l'id de l'utilisateur edite
$caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer)
|| (($user->id != $id) && $user->rights->user->user->creer)); || (($user->id != $id) && $user->rights->user->user->creer));
@ -47,11 +46,15 @@ if ($id)
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
if ($user->id <> $id && !$canreaduser) accessforbidden(); if ($user->id <> $id && !$canreaduser) {
accessforbidden();
}
$dirtop = "../core/menus/standard"; $dirtop = "../core/menus/standard";
$dirleft = "../core/menus/standard"; $dirleft = "../core/menus/standard";
@ -81,7 +84,9 @@ $hookmanager->initHooks(array('usercard', 'userihm', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
if ($action == 'update' && ($caneditfield || !empty($user->admin))) { if ($action == 'update' && ($caneditfield || !empty($user->admin))) {
@ -122,16 +127,20 @@ if (empty($reshook)) {
if ($val == '') { if ($val == '') {
$tabparam['THEME_ELDY_TOPMENU_BACK1'] = ''; $tabparam['THEME_ELDY_TOPMENU_BACK1'] = '';
} else { } else {
$tabparam['THEME_ELDY_TOPMENU_BACK1'] = join(',', $tabparam['THEME_ELDY_TOPMENU_BACK1'] = join(
colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1', 'alphanohtml'), array())); ',',
colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1', 'alphanohtml'), array())
);
} }
$val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1', 'alphanohtml'), array())))); $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1', 'alphanohtml'), array()))));
if ($val == '') { if ($val == '') {
$tabparam['THEME_ELDY_BACKTITLE1'] = ''; $tabparam['THEME_ELDY_BACKTITLE1'] = '';
} else { } else {
$tabparam['THEME_ELDY_BACKTITLE1'] = join(',', $tabparam['THEME_ELDY_BACKTITLE1'] = join(
colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1', 'alphanohtml'), array())); ',',
colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1', 'alphanohtml'), array())
);
} }
if (GETPOST('check_THEME_ELDY_USE_HOVER') == 'on') { if (GETPOST('check_THEME_ELDY_USE_HOVER') == 'on') {
@ -174,21 +183,36 @@ llxHeader();
// List of possible landing pages // List of possible landing pages
$tmparray = array('index.php'=>'Dashboard'); $tmparray = array('index.php'=>'Dashboard');
if (!empty($conf->societe->enabled)) $tmparray['societe/index.php?mainmenu=companies&leftmenu='] = 'ThirdPartiesArea'; if (!empty($conf->societe->enabled)) {
if (!empty($conf->projet->enabled)) $tmparray['projet/index.php?mainmenu=project&leftmenu='] = 'ProjectsArea'; $tmparray['societe/index.php?mainmenu=companies&leftmenu='] = 'ThirdPartiesArea';
if (!empty($conf->holiday->enabled) || !empty($conf->expensereport->enabled)) $tmparray['hrm/index.php?mainmenu=hrm&leftmenu='] = 'HRMArea'; // TODO Complete list with first level of menus }
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) $tmparray['product/index.php?mainmenu=products&leftmenu='] = 'ProductsAndServicesArea'; if (!empty($conf->projet->enabled)) {
if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->contrat->enabled)) $tmparray['comm/index.php?mainmenu=commercial&leftmenu='] = 'CommercialArea'; $tmparray['projet/index.php?mainmenu=project&leftmenu='] = 'ProjectsArea';
if (!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled)) $tmparray['compta/index.php?mainmenu=compta&leftmenu='] = 'AccountancyTreasuryArea'; }
if (!empty($conf->adherent->enabled)) $tmparray['adherents/index.php?mainmenu=members&leftmenu='] = 'MembersArea'; if (!empty($conf->holiday->enabled) || !empty($conf->expensereport->enabled)) {
if (!empty($conf->agenda->enabled)) $tmparray['comm/action/index.php?mainmenu=agenda&leftmenu='] = 'Agenda'; $tmparray['hrm/index.php?mainmenu=hrm&leftmenu='] = 'HRMArea'; // TODO Complete list with first level of menus
}
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
$tmparray['product/index.php?mainmenu=products&leftmenu='] = 'ProductsAndServicesArea';
}
if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->contrat->enabled)) {
$tmparray['comm/index.php?mainmenu=commercial&leftmenu='] = 'CommercialArea';
}
if (!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled)) {
$tmparray['compta/index.php?mainmenu=compta&leftmenu='] = 'AccountancyTreasuryArea';
}
if (!empty($conf->adherent->enabled)) {
$tmparray['adherents/index.php?mainmenu=members&leftmenu='] = 'MembersArea';
}
if (!empty($conf->agenda->enabled)) {
$tmparray['comm/action/index.php?mainmenu=agenda&leftmenu='] = 'Agenda';
}
$head = user_prepare_head($object); $head = user_prepare_head($object);
$title = $langs->trans("User"); $title = $langs->trans("User");
if ($action == 'edit') if ($action == 'edit') {
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -196,8 +220,7 @@ if ($action == 'edit')
} }
if ($action == 'edit') if ($action == 'edit') {
{
print dol_get_fiche_head($head, 'guisetup', $title, -1, 'user'); print dol_get_fiche_head($head, 'guisetup', $title, -1, 'user');
$linkback = ''; $linkback = '';
@ -208,8 +231,7 @@ if ($action == 'edit')
dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {/*
{/*
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
$("#main_lang_default").change(function() { $("#main_lang_default").change(function() {
@ -222,8 +244,7 @@ if ($action == 'edit')
}); });
</script>';*/ </script>';*/
} }
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
function init_myfunc() function init_myfunc()
@ -357,10 +378,11 @@ if ($action == 'edit')
print empty($dolibarr_main_demo) ? '' : ' disabled="disabled"'; // Disabled for demo print empty($dolibarr_main_demo) ? '' : ' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").'</td>'; print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'; print '<td>';
if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) {
{
print $langs->trans($tmparray[$object->conf->MAIN_LANDING_PAGE]); print $langs->trans($tmparray[$object->conf->MAIN_LANDING_PAGE]);
} else print $object->conf->MAIN_LANDING_PAGE; } 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 $form->selectarray('MAIN_LANDING_PAGE', $tmparray, (! empty($object->conf->MAIN_LANDING_PAGE)?$object->conf->MAIN_LANDING_PAGE:''), 0, 0, 0, '', 1);
print '</td></tr>'; print '</td></tr>';
@ -371,7 +393,9 @@ if ($action == 'edit')
print '<td class="nowrap" width="20%"><input class="oddeven" type="checkbox" disabled '.(!empty($object->conf->AGENDA_DEFAULT_VIEW) ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>'; print '<td class="nowrap" width="20%"><input class="oddeven" type="checkbox" disabled '.(!empty($object->conf->AGENDA_DEFAULT_VIEW) ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'."\n"; print '<td>'."\n";
$tmplist = array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); $tmplist = array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
if (!empty($object->conf->AGENDA_DEFAULT_VIEW)) print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $object->conf->AGENDA_DEFAULT_VIEW, 0, 0, 0, '', 0, 0, 1); if (!empty($object->conf->AGENDA_DEFAULT_VIEW)) {
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $object->conf->AGENDA_DEFAULT_VIEW, 0, 0, 0, '', 0, 0, 1);
}
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Max size for lists // Max size for lists
@ -390,12 +414,10 @@ if ($action == 'edit')
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if (empty($user->admin) && !empty($dolibarr_main_demo)) if (empty($user->admin) && !empty($dolibarr_main_demo)) {
{
print "<a class=\"butActionRefused classfortooltip\" title=\"".$langs->trans("FeatureDisabledInDemo")."\" href=\"#\">".$langs->trans("Modify")."</a>"; print "<a class=\"butActionRefused classfortooltip\" title=\"".$langs->trans("FeatureDisabledInDemo")."\" href=\"#\">".$langs->trans("Modify")."</a>";
} else { } else {
if ($caneditfield || !empty($user->admin)) // Si utilisateur edite = utilisateur courant (pas besoin de droits particulier car il s'agit d'une page de modif d'output et non de données) ou si admin if ($caneditfield || !empty($user->admin)) { // Si utilisateur edite = utilisateur courant (pas besoin de droits particulier car il s'agit d'une page de modif d'output et non de données) ou si admin
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("Modify").'</a>';
} else { } else {
print "<a class=\"butActionRefused classfortooltip\" title=\"".$langs->trans("NotEnoughPermissions")."\" href=\"#\">".$langs->trans("Modify")."</a>"; print "<a class=\"butActionRefused classfortooltip\" title=\"".$langs->trans("NotEnoughPermissions")."\" href=\"#\">".$langs->trans("Modify")."</a>";
@ -405,8 +427,7 @@ if ($action == 'edit')
print '</div>'; print '</div>';
} }
if ($action == 'edit') if ($action == 'edit') {
{
print '</form>'; print '</form>';
} }

View File

@ -29,21 +29,24 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; if (!empty($conf->ldap->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
}
// Load translation files required by page // Load translation files required by page
$langs->loadLangs(array('errors', 'users', 'companies', 'ldap', 'other')); $langs->loadLangs(array('errors', 'users', 'companies', 'ldap', 'other'));
// Security check // Security check
if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) {
{
header("Location: ".DOL_URL_ROOT.'/'); header("Location: ".DOL_URL_ROOT.'/');
exit; exit;
} }
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$mode = $dolibarr_main_authentication; $mode = $dolibarr_main_authentication;
if (!$mode) $mode = 'http'; if (!$mode) {
$mode = 'http';
}
$username = GETPOST('username', 'alphanohtml'); $username = GETPOST('username', 'alphanohtml');
$passwordhash = GETPOST('passwordhash', 'alpha'); $passwordhash = GETPOST('passwordhash', 'alpha');
@ -53,11 +56,21 @@ $conf->entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : 1);
$hookmanager->initHooks(array('passwordforgottenpage')); $hookmanager->initHooks(array('passwordforgottenpage'));
if (GETPOST('dol_hide_leftmenu', 'alpha') || !empty($_SESSION['dol_hide_leftmenu'])) $conf->dol_hide_leftmenu = 1; if (GETPOST('dol_hide_leftmenu', 'alpha') || !empty($_SESSION['dol_hide_leftmenu'])) {
if (GETPOST('dol_hide_topmenu', 'alpha') || !empty($_SESSION['dol_hide_topmenu'])) $conf->dol_hide_topmenu = 1; $conf->dol_hide_leftmenu = 1;
if (GETPOST('dol_optimize_smallscreen', 'alpha') || !empty($_SESSION['dol_optimize_smallscreen'])) $conf->dol_optimize_smallscreen = 1; }
if (GETPOST('dol_no_mouse_hover', 'alpha') || !empty($_SESSION['dol_no_mouse_hover'])) $conf->dol_no_mouse_hover = 1; if (GETPOST('dol_hide_topmenu', 'alpha') || !empty($_SESSION['dol_hide_topmenu'])) {
if (GETPOST('dol_use_jmobile', 'alpha') || !empty($_SESSION['dol_use_jmobile'])) $conf->dol_use_jmobile = 1; $conf->dol_hide_topmenu = 1;
}
if (GETPOST('dol_optimize_smallscreen', 'alpha') || !empty($_SESSION['dol_optimize_smallscreen'])) {
$conf->dol_optimize_smallscreen = 1;
}
if (GETPOST('dol_no_mouse_hover', 'alpha') || !empty($_SESSION['dol_no_mouse_hover'])) {
$conf->dol_no_mouse_hover = 1;
}
if (GETPOST('dol_use_jmobile', 'alpha') || !empty($_SESSION['dol_use_jmobile'])) {
$conf->dol_use_jmobile = 1;
}
/** /**
@ -72,16 +85,13 @@ if ($reshook < 0) {
if (empty($reshook)) { if (empty($reshook)) {
// Validate new password // Validate new password
if ($action == 'validatenewpassword' && $username && $passwordhash) if ($action == 'validatenewpassword' && $username && $passwordhash) {
{
$edituser = new User($db); $edituser = new User($db);
$result = $edituser->fetch('', $_GET["username"]); $result = $edituser->fetch('', $_GET["username"]);
if ($result < 0) if ($result < 0) {
{
$message = '<div class="error">'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'</div>'; $message = '<div class="error">'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'</div>';
} else { } else {
if (dol_verifyHash($edituser->pass_temp, $passwordhash)) if (dol_verifyHash($edituser->pass_temp, $passwordhash)) {
{
// Clear session // Clear session
unset($_SESSION['dol_login']); unset($_SESSION['dol_login']);
$_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page $_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page
@ -97,27 +107,23 @@ if (empty($reshook)) {
} }
} }
// Action modif mot de passe // Action modif mot de passe
if ($action == 'buildnewpassword' && $username) if ($action == 'buildnewpassword' && $username) {
{
$sessionkey = 'dol_antispam_value'; $sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
// Verify code // Verify code
if (!$ok) if (!$ok) {
{
$message = '<div class="error">'.$langs->trans("ErrorBadValueForCode").'</div>'; $message = '<div class="error">'.$langs->trans("ErrorBadValueForCode").'</div>';
} else { } else {
$isanemail = preg_match('/@/', $username); $isanemail = preg_match('/@/', $username);
$edituser = new User($db); $edituser = new User($db);
$result = $edituser->fetch('', $username, '', 1); $result = $edituser->fetch('', $username, '', 1);
if ($result == 0 && $isanemail) if ($result == 0 && $isanemail) {
{
$result = $edituser->fetch('', '', '', 1, -1, $username); $result = $edituser->fetch('', '', '', 1, -1, $username);
} }
if ($result <= 0 && $edituser->error == 'USERNOTFOUND') if ($result <= 0 && $edituser->error == 'USERNOTFOUND') {
{
$message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">'; $message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">';
if (!$isanemail) { if (!$isanemail) {
$message .= $langs->trans("IfLoginExistPasswordRequestSent"); $message .= $langs->trans("IfLoginExistPasswordRequestSent");
@ -127,19 +133,16 @@ if (empty($reshook)) {
$message .= '</div>'; $message .= '</div>';
$username = ''; $username = '';
} else { } else {
if (!$edituser->email) if (!$edituser->email) {
{
$message = '<div class="error">'.$langs->trans("ErrorLoginHasNoEmail").'</div>'; $message = '<div class="error">'.$langs->trans("ErrorLoginHasNoEmail").'</div>';
} else { } else {
$newpassword = $edituser->setPassword($user, '', 1); $newpassword = $edituser->setPassword($user, '', 1);
if ($newpassword < 0) if ($newpassword < 0) {
{
// Failed // Failed
$message = '<div class="error">'.$langs->trans("ErrorFailedToChangePassword").'</div>'; $message = '<div class="error">'.$langs->trans("ErrorFailedToChangePassword").'</div>';
} else { } else {
// Success // Success
if ($edituser->send_password($user, $newpassword, 1) > 0) if ($edituser->send_password($user, $newpassword, 1) > 0) {
{
$message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">'; $message = '<div class="warning paddingtopbottom'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">';
if (!$isanemail) { if (!$isanemail) {
$message .= $langs->trans("IfLoginExistPasswordRequestSent"); $message .= $langs->trans("IfLoginExistPasswordRequestSent");
@ -168,46 +171,49 @@ $dol_url_root = DOL_URL_ROOT;
// Title // Title
$title = 'Dolibarr '.DOL_VERSION; $title = 'Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $conf->global->MAIN_APPLICATION_TITLE; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$title = $conf->global->MAIN_APPLICATION_TITLE;
}
// Select templates // Select templates
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/passwordforgotten.tpl.php")) if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/passwordforgotten.tpl.php")) {
{
$template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/"; $template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/";
} else { } else {
$template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/";
} }
if (!$username) $focus_element = 'username'; if (!$username) {
else $focus_element = 'password'; $focus_element = 'username';
} else {
$focus_element = 'password';
}
// Send password button enabled ? // Send password button enabled ?
$disabled = 'disabled'; $disabled = 'disabled';
if (preg_match('/dolibarr/i', $mode)) $disabled = ''; if (preg_match('/dolibarr/i', $mode)) {
if (!empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) $disabled = ''; // To force button enabled $disabled = '';
}
if (!empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) {
$disabled = ''; // To force button enabled
}
// Show logo (search in order: small company logo, large company logo, theme logo, common logo) // Show logo (search in order: small company logo, large company logo, theme logo, common logo)
$width = 0; $width = 0;
$rowspan = 2; $rowspan = 2;
$urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
{
$urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small); $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
} elseif (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) } elseif (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
{
$urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo); $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
$width = 128; $width = 128;
} elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.svg')) } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.svg')) {
{
$urllogo = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.svg'; $urllogo = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.svg';
} elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
{
$urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
} }
// Security graphical code // Security graphical code
if (function_exists("imagecreatefrompng") && !$disabled) if (function_exists("imagecreatefrompng") && !$disabled) {
{
$captcha = 1; $captcha = 1;
$captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"');
} }

View File

@ -26,7 +26,9 @@
* \brief Page to set permission of a user record * \brief Page to set permission of a user record
*/ */
if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET if (!defined('CSRFCHECK_WITH_TOKEN')) {
define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
}
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
@ -43,15 +45,16 @@ $module = GETPOST('module', 'alpha');
$rights = GETPOST('rights', 'int'); $rights = GETPOST('rights', 'int');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userperms'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userperms'; // To manage different context of search
if (!isset($id) || empty($id)) accessforbidden(); if (!isset($id) || empty($id)) {
accessforbidden();
}
// Define if user can read permissions // Define if user can read permissions
$canreaduser = ($user->admin || $user->rights->user->user->lire); $canreaduser = ($user->admin || $user->rights->user->user->lire);
// Define if user can modify other users and permissions // Define if user can modify other users and permissions
$caneditperms = ($user->admin || $user->rights->user->user->creer); $caneditperms = ($user->admin || $user->rights->user->user->creer);
// Advanced permissions // Advanced permissions
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
{
$canreaduser = ($user->admin || ($user->rights->user->user->lire && $user->rights->user->user_advance->readperms)); $canreaduser = ($user->admin || ($user->rights->user->user->lire && $user->rights->user->user_advance->readperms));
$caneditselfperms = ($user->id == $id && $user->rights->user->self_advance->writeperms); $caneditselfperms = ($user->id == $id && $user->rights->user->self_advance->writeperms);
$caneditperms = (($caneditperms || $caneditselfperms) ? 1 : 0); $caneditperms = (($caneditperms || $caneditselfperms) ? 1 : 0);
@ -59,16 +62,19 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
// Security check // Security check
$socid = 0; $socid = 0;
if (isset($user->socid) && $user->socid > 0) $socid = $user->socid; if (isset($user->socid) && $user->socid > 0) {
$socid = $user->socid;
}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
// A user can always read its own card if not advanced perms enabled, or if he has advanced perms, except for admin // A user can always read its own card if not advanced perms enabled, or if he has advanced perms, except for admin
if ($user->id == $id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms) && empty($user->admin))) if ($user->id == $id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms) && empty($user->admin))) {
{
accessforbidden(); accessforbidden();
} }
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
if ($user->id <> $id && !$canreaduser) accessforbidden(); if ($user->id <> $id && !$canreaduser) {
accessforbidden();
}
$object = new User($db); $object = new User($db);
$object->fetch($id, '', '', 1); $object->fetch($id, '', '', 1);
@ -86,15 +92,16 @@ $hookmanager->initHooks(array('usercard', 'userperms', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
if ($action == 'addrights' && $caneditperms && $confirm == 'yes') { if ($action == 'addrights' && $caneditperms && $confirm == 'yes') {
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($object->id); $edituser->fetch($object->id);
$result = $edituser->addrights($rights, $module, '', $entity); $result = $edituser->addrights($rights, $module, '', $entity);
if ($result < 0) if ($result < 0) {
{
setEventMessages($edituser->error, $edituser->errors, 'errors'); setEventMessages($edituser->error, $edituser->errors, 'errors');
} }
@ -113,8 +120,7 @@ if (empty($reshook)) {
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($object->id); $edituser->fetch($object->id);
$result = $edituser->delrights($rights, $module, '', $entity); $result = $edituser->delrights($rights, $module, '', $entity);
if ($result < 0) if ($result < 0) {
{
setEventMessages($edituser->error, $edituser->errors, 'errors'); setEventMessages($edituser->error, $edituser->errors, 'errors');
} }
@ -151,33 +157,25 @@ $db->begin();
$modules = array(); $modules = array();
$modulesdir = dolGetModulesDirs(); $modulesdir = dolGetModulesDirs();
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir) {
{
$handle = @opendir(dol_osencode($dir)); $handle = @opendir(dol_osencode($dir));
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
{
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
{
$modName = substr($file, 0, dol_strlen($file) - 10); $modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName) if ($modName) {
{
include_once $dir.$file; include_once $dir.$file;
$objMod = new $modName($db); $objMod = new $modName($db);
// Load all lang files of module // Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles)) if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
{ foreach ($objMod->langfiles as $domain) {
foreach ($objMod->langfiles as $domain)
{
$langs->load($domain); $langs->load($domain);
} }
} }
// Load all permissions // Load all permissions
if ($objMod->rights_class) if ($objMod->rights_class) {
{
$ret = $objMod->insert_permissions(0, $entity); $ret = $objMod->insert_permissions(0, $entity);
$modules[$objMod->rights_class] = $objMod; $modules[$objMod->rights_class] = $objMod;
//print "modules[".$objMod->rights_class."]=$objMod;"; //print "modules[".$objMod->rights_class."]=$objMod;";
@ -200,12 +198,10 @@ $sql .= " AND ur.fk_user = ".$object->id;
dol_syslog("get user perms", LOG_DEBUG); dol_syslog("get user perms", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
array_push($permsuser, $obj->fk_id); array_push($permsuser, $obj->fk_id);
$i++; $i++;
@ -227,15 +223,14 @@ $sql .= " AND gu.fk_user = ".$object->id;
dol_syslog("get user perms", LOG_DEBUG); dol_syslog("get user perms", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if (!isset($permsgroupbyentity[$obj->entity])) if (!isset($permsgroupbyentity[$obj->entity])) {
$permsgroupbyentity[$obj->entity] = array(); $permsgroupbyentity[$obj->entity] = array();
}
array_push($permsgroupbyentity[$obj->entity], $obj->fk_id); array_push($permsgroupbyentity[$obj->entity], $obj->fk_id);
$i++; $i++;
} }
@ -260,13 +255,19 @@ dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $use
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); if ($user->admin) {
print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"));
}
// Show warning about external users // Show warning about external users
if (empty($user->socid)) print info_admin(showModulesExludedForExternal($modules))."\n"; if (empty($user->socid)) {
print info_admin(showModulesExludedForExternal($modules))."\n";
}
$parameters = array('permsgroupbyentity'=>$permsgroupbyentity); $parameters = array('permsgroupbyentity'=>$permsgroupbyentity);
$reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
print "\n"; print "\n";
@ -275,10 +276,8 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>'; print '<td>'.$langs->trans("Module").'</td>';
if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) {
{ if ($caneditperms) {
if ($caneditperms)
{
print '<td class="center nowrap">'; print '<td class="center nowrap">';
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules&amp;confirm=yes&amp;token='.newToken().'">'.$langs->trans("All")."</a>"; print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules&amp;confirm=yes&amp;token='.newToken().'">'.$langs->trans("All")."</a>";
print ' / '; print ' / ';
@ -288,7 +287,9 @@ if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->ad
print '<td class="center" width="24">&nbsp;</td>'; print '<td class="center" width="24">&nbsp;</td>';
} }
print '<td>'.$langs->trans("Permissions").'</td>'; print '<td>'.$langs->trans("Permissions").'</td>';
if ($user->admin) print '<td class="right">'.$langs->trans("ID").'</td>'; if ($user->admin) {
print '<td class="right">'.$langs->trans("ID").'</td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
//print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS; //print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS;
@ -296,32 +297,29 @@ $sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql .= " AND r.entity = ".$entity; $sql .= " AND r.entity = ".$entity;
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
$sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
}
$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$oldmod = ''; $oldmod = '';
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
if (empty($modules[$obj->module])) if (empty($modules[$obj->module])) {
{
$i++; $i++;
continue; continue;
} }
// Save field module_position in database if value is still zero // Save field module_position in database if value is still zero
if (empty($obj->module_position)) if (empty($obj->module_position)) {
{ if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) {
if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0))
{
// TODO Define familyposition // TODO Define familyposition
$family = $modules[$obj->module]->family_position; $family = $modules[$obj->module]->family_position;
$familyposition = 0; $familyposition = 0;
@ -332,8 +330,7 @@ if ($result)
} }
} }
if (isset($obj->module) && ($oldmod <> $obj->module)) if (isset($obj->module) && ($oldmod <> $obj->module)) {
{
$oldmod = $obj->module; $oldmod = $obj->module;
// Break detected, we get objMod // Break detected, we get objMod
@ -346,10 +343,8 @@ if ($result)
print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'"></a>'; print '<a name="'.$objMod->getName().'"></a>';
print '</td>'; print '</td>';
if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) {
{ if ($caneditperms) {
if ($caneditperms)
{
print '<td class="center nowrap">'; print '<td class="center nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'&amp;confirm=yes&amp;token='.newToken().'">'.$langs->trans("All")."</a>"; print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'&amp;confirm=yes&amp;token='.newToken().'">'.$langs->trans("All")."</a>";
print ' / '; print ' / ';
@ -358,8 +353,7 @@ if ($result)
} }
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} else { } else {
if ($caneditperms) if ($caneditperms) {
{
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
@ -367,7 +361,9 @@ if ($result)
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
// Permission id // Permission id
if ($user->admin) print '<td class="right"></td>'; if ($user->admin) {
print '<td class="right"></td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
} }
@ -381,19 +377,15 @@ if ($result)
print '</td>'; print '</td>';
// Permission and tick // Permission and tick
if (!empty($object->admin) && !empty($objMod->rights_admin_allowed)) // Permission granted because admin if (!empty($object->admin) && !empty($objMod->rights_admin_allowed)) { // Permission granted because admin
{ if ($caneditperms) {
if ($caneditperms)
{
print '<td class="center">'.img_picto($langs->trans("Administrator"), 'star').'</td>'; print '<td class="center">'.img_picto($langs->trans("Administrator"), 'star').'</td>';
} }
print '<td class="center nowrap">'; print '<td class="center nowrap">';
print img_picto($langs->trans("Active"), 'tick'); print img_picto($langs->trans("Active"), 'tick');
print '</td>'; print '</td>';
} elseif (in_array($obj->id, $permsuser)) // Permission granted by user } elseif (in_array($obj->id, $permsuser)) { // Permission granted by user
{ if ($caneditperms) {
if ($caneditperms)
{
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">';
//print img_edit_remove($langs->trans("Remove")); //print img_edit_remove($langs->trans("Remove"));
print img_picto($langs->trans("Remove"), 'switch_on'); print img_picto($langs->trans("Remove"), 'switch_on');
@ -402,12 +394,9 @@ if ($result)
print '<td class="center nowrap">'; print '<td class="center nowrap">';
print img_picto($langs->trans("Active"), 'tick'); print img_picto($langs->trans("Active"), 'tick');
print '</td>'; print '</td>';
} elseif (is_array($permsgroupbyentity[$entity])) } elseif (is_array($permsgroupbyentity[$entity])) {
{ if (in_array($obj->id, $permsgroupbyentity[$entity])) { // Permission granted by group
if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission granted by group if ($caneditperms) {
{
if ($caneditperms)
{
print '<td class="center">'; print '<td class="center">';
print $form->textwithtooltip($langs->trans("Inherited"), $langs->trans("PermissionInheritedFromAGroup")); print $form->textwithtooltip($langs->trans("Inherited"), $langs->trans("PermissionInheritedFromAGroup"));
print '</td>'; print '</td>';
@ -417,8 +406,7 @@ if ($result)
print '</td>'; print '</td>';
} else { } else {
// Do not own permission // Do not own permission
if ($caneditperms) if ($caneditperms) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">';
//print img_edit_add($langs->trans("Add")); //print img_edit_add($langs->trans("Add"));
print img_picto($langs->trans("Add"), 'switch_off'); print img_picto($langs->trans("Add"), 'switch_off');
@ -428,8 +416,7 @@ if ($result)
} }
} else { } else {
// Do not own permission // Do not own permission
if ($caneditperms) if ($caneditperms) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'&amp;confirm=yes&amp;token='.newToken().'">';
//print img_edit_add($langs->trans("Add")); //print img_edit_add($langs->trans("Add"));
print img_picto($langs->trans("Add"), 'switch_off'); print img_picto($langs->trans("Add"), 'switch_off');
@ -450,19 +437,25 @@ if ($result)
print '</td>'; print '</td>';
// Permission id // Permission id
if ($user->admin) print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>'; if ($user->admin) {
print '<td class="right"><span class="opacitymedium">'.$obj->id.'</span></td>';
}
print '</tr>'."\n"; print '</tr>'."\n";
$i++; $i++;
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
print '</table>'; print '</table>';
print '</div>'; print '</div>';
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
print dol_get_fiche_end(); print dol_get_fiche_end();

View File

@ -36,14 +36,15 @@ $id = GETPOST('id', 'int');
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid > 0) $socid = $user->socid; if ($user->socid > 0) {
$socid = $user->socid;
}
$feature2 = 'user'; $feature2 = 'user';
$result = restrictedArea($user, 'user', $id, 'user', $feature2); $result = restrictedArea($user, 'user', $id, 'user', $feature2);
$result = $user2->fetch($id); $result = $user2->fetch($id);
if ($result <= 0) if ($result <= 0) {
{
dol_print_error($user2->error); dol_print_error($user2->error);
exit; exit;
} }
@ -51,8 +52,7 @@ if ($result <= 0)
$physicalperson = 1; $physicalperson = 1;
$company = new Societe($db); $company = new Societe($db);
if ($user2->socid) if ($user2->socid) {
{
$result = $company->fetch($user2->socid); $result = $company->fetch($user2->socid);
} }
@ -79,33 +79,32 @@ $v->setNote($user2->note);
$v->setTitle($user2->poste); $v->setTitle($user2->poste);
// Data from linked company // Data from linked company
if ($company->id) if ($company->id) {
{
$v->setURL($company->url, "TYPE=WORK"); $v->setURL($company->url, "TYPE=WORK");
if (!$user2->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); if (!$user2->phone_pro) {
if (!$user2->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
if (!$user2->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); }
if (!$user2->fax) {
$v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
}
if (!$user2->zip) {
$v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
}
// when company e-mail is empty, use only user e-mail // when company e-mail is empty, use only user e-mail
if (empty(trim($company->email))) if (empty(trim($company->email))) {
{
// was set before, don't set twice // was set before, don't set twice
} } elseif (empty(trim($user2->email))) {
// when user e-mail is empty, use only company e-mail // when user e-mail is empty, use only company e-mail
elseif (empty(trim($user2->email)))
{
$v->setEmail($company->email); $v->setEmail($company->email);
} } elseif (strtolower(end(explode("@", $user2->email))) == strtolower(end(explode("@", $company->email)))) {
// when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second) // when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second)
elseif (strtolower(end(explode("@", $user2->email))) == strtolower(end(explode("@", $company->email))))
{
$v->setEmail($user2->email); $v->setEmail($user2->email);
// support by Microsoft Outlook (2019 and possible earlier) // support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($company->email, 'INTERNET'); $v->setEmail($company->email, 'INTERNET');
} } else {
// when e-mail of user and company complete different use company e-mail at first (and user e-mail at second) // when e-mail of user and company complete different use company e-mail at first (and user e-mail at second)
else {
$v->setEmail($company->email); $v->setEmail($company->email);
// support by Microsoft Outlook (2019 and possible earlier) // support by Microsoft Outlook (2019 and possible earlier)
@ -113,12 +112,16 @@ if ($company->id)
} }
// Si user lie a un tiers non de type "particulier" // Si user lie a un tiers non de type "particulier"
if ($user2->typent_code != 'TE_PRIVATE') $v->setOrg($company->name); if ($user2->typent_code != 'TE_PRIVATE') {
$v->setOrg($company->name);
}
} }
// Personal informations // Personal informations
$v->setPhoneNumber($user2->phone_perso, "TYPE=HOME;VOICE"); $v->setPhoneNumber($user2->phone_perso, "TYPE=HOME;VOICE");
if ($user2->birth) $v->setBirthday($user2->birth); if ($user2->birth) {
$v->setBirthday($user2->birth);
}
$db->close(); $db->close();