diff --git a/htdocs/user/admin/group_extrafields.php b/htdocs/user/admin/group_extrafields.php
index fd71d43d4f0..627af1c3b9d 100644
--- a/htdocs/user/admin/group_extrafields.php
+++ b/htdocs/user/admin/group_extrafields.php
@@ -38,13 +38,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$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');
$attrname = GETPOST('attrname', 'alpha');
$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
-if ($action != 'create' && $action != 'edit')
-{
+if ($action != 'create' && $action != 'edit') {
print '
';
@@ -183,8 +194,7 @@ print '
'.$langs->trans("Color").' | ';
print "";
$i = 1;
-while ($i <= $MAXAGENDA)
-{
+while ($i <= $MAXAGENDA) {
$key = $i;
$name = 'AGENDA_EXT_NAME_'.$id.'_'.$key;
$src = 'AGENDA_EXT_SRC_'.$id.'_'.$key;
diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php
index 20369e37d69..65bf7c5c8ac 100644
--- a/htdocs/user/bank.php
+++ b/htdocs/user/bank.php
@@ -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/date.lib.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->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';
+if (!empty($conf->holiday->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.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
$langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries'));
@@ -47,35 +53,44 @@ $cancel = GETPOST('cancel', 'alpha');
// Security check
$socid = 0;
-if ($user->socid > 0) $socid = $user->socid;
+if ($user->socid > 0) {
+ $socid = $user->socid;
+}
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
// Ok if user->rights->salaries->read or user->rights->hrm->read
//$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2);
$ok = false;
-if ($user->id == $id) $ok = true; // A user can always read its own card
-if (!empty($user->rights->salaries->read)) $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)
-{
+if ($user->id == $id) {
+ $ok = true; // A user can always read its own card
+}
+if (!empty($user->rights->salaries->read)) {
+ $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();
}
$object = new User($db);
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref, '', 1);
$object->getrights();
}
$account = new UserBankAccount($db);
-if (!$bankid)
-{
+if (!$bankid) {
$account->fetch(0, '', $id);
} else {
$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));
@@ -84,8 +99,7 @@ $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty(
* Actions
*/
-if ($action == 'add' && !$cancel)
-{
+if ($action == 'add' && !$cancel) {
$account->userid = $object->id;
$account->bank = GETPOST('bank', 'alpha');
@@ -103,8 +117,7 @@ if ($action == 'add' && !$cancel)
$result = $account->create($user);
- if (!$result)
- {
+ if (!$result) {
setEventMessages($account->error, $account->errors, 'errors');
$action = 'edit'; // Force chargement page edition
} else {
@@ -113,52 +126,51 @@ if ($action == 'add' && !$cancel)
}
}
-if ($action == 'update' && !$cancel)
-{
+if ($action == 'update' && !$cancel) {
$account->userid = $object->id;
/*
- if ($action == 'update' && !$cancel)
- {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ if ($action == 'update' && !$cancel)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- if ($canedituser) // Case we can edit all field
- {
- $error = 0;
+ if ($canedituser) // Case we can edit all field
+ {
+ $error = 0;
- if (!$error)
- {
- $objectuser->fetch($id);
+ if (!$error)
+ {
+ $objectuser->fetch($id);
- $objectuser->oldcopy = clone $objectuser;
+ $objectuser->oldcopy = clone $objectuser;
- $db->begin();
+ $db->begin();
- $objectuser->default_range = GETPOST('default_range');
- $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat');
+ $objectuser->default_range = GETPOST('default_range');
+ $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat');
- if (!$error) {
- $ret = $objectuser->update($user);
- if ($ret < 0) {
- $error++;
- if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
- $langs->load("errors");
- setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors');
- } else {
- setEventMessages($objectuser->error, $objectuser->errors, 'errors');
- }
- }
- }
+ if (!$error) {
+ $ret = $objectuser->update($user);
+ if ($ret < 0) {
+ $error++;
+ if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors');
+ } else {
+ setEventMessages($objectuser->error, $objectuser->errors, 'errors');
+ }
+ }
+ }
- if (!$error && !count($objectuser->errors)) {
- setEventMessages($langs->trans("UserModified"), null, 'mesgs');
- $db->commit();
- } else {
- $db->rollback();
- }
- }
- }
- }*/
+ if (!$error && !count($objectuser->errors)) {
+ setEventMessages($langs->trans("UserModified"), null, 'mesgs');
+ $db->commit();
+ } else {
+ $db->rollback();
+ }
+ }
+ }
+ }*/
$account->bank = GETPOST('bank', 'alpha');
$account->label = GETPOST('label', 'alpha');
@@ -188,28 +200,36 @@ if ($action == 'update' && !$cancel)
if ($action == 'setpersonal_email') {
$object->personal_email = (string) GETPOST('personal_email', 'alphanohtml');
$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
if ($action == 'setpersonal_mobile') {
$object->personal_mobile = (string) GETPOST('personal_mobile', 'alphanohtml');
$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
if ($action == 'setdefault_c_exp_tax_cat') {
$object->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat', 'int');
$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
if ($action == 'setdefault_range') {
$object->default_range = GETPOST('default_range', 'int');
$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);
-if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer)
-{
+if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) {
print '
';
}
-if ($id && $action == 'edit' && $user->rights->user->user->creer) print '';
+if ($id && $action == 'edit' && $user->rights->user->user->creer) {
+ print '';
+}
-if ($id && $action == 'create' && $user->rights->user->user->creer) print '';
+if ($id && $action == 'create' && $user->rights->user->user->creer) {
+ print '';
+}
// End of page
llxFooter();
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index c5820db60b7..45da6f2d6d0 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -48,10 +48,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
-if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
-if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
-if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
-if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+if (!empty($conf->ldap->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
+}
+if (!empty($conf->adherent->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+}
+if (!empty($conf->categorie->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+}
+if (!empty($conf->stock->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+}
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
@@ -74,15 +82,13 @@ $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
$candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer);
$canreadgroup = $canreaduser;
$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);
$caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write);
}
// 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
$caneditfield = ((($user->id == $id) && $user->rights->user->self->creer)
|| (($user->id != $id) && $user->rights->user->user->creer));
@@ -92,11 +98,15 @@ if ($id)
// Security check
$socid = 0;
-if ($user->socid > 0) $socid = $user->socid;
+if ($user->socid > 0) {
+ $socid = $user->socid;
+}
$feature2 = 'user';
$result = restrictedArea($user, 'user', $id, 'user', $feature2);
-if ($user->id <> $id && !$canreaduser) accessforbidden();
+if ($user->id <> $id && !$canreaduser) {
+ accessforbidden();
+}
// Load translation files required by page
$langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks'));
@@ -120,7 +130,9 @@ $hookmanager->initHooks(array('usercard', 'globalcard'));
$parameters = array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
if (empty($reshook)) {
if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) {
@@ -153,12 +165,9 @@ if (empty($reshook)) {
}
}
- if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser)
- {
- if ($id <> $user->id)
- {
- if (!GETPOSTISSET('token'))
- {
+ if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) {
+ if ($id <> $user->id) {
+ if (!GETPOSTISSET('token')) {
print 'Error, token required for this critical operation';
exit;
}
@@ -315,10 +324,8 @@ if (empty($reshook)) {
}
// Action add usergroup
- if (($action == 'addgroup' || $action == 'removegroup') && $caneditgroup)
- {
- if ($group)
- {
+ if (($action == 'addgroup' || $action == 'removegroup') && $caneditgroup) {
+ if ($group) {
$editgroup = new UserGroup($db);
$editgroup->fetch($group);
$editgroup->oldcopy = clone $editgroup;
@@ -340,12 +347,10 @@ if (empty($reshook)) {
}
}
- if ($action == 'update' && !$cancel)
- {
+ if ($action == 'update' && !$cancel) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- if ($caneditfield) // Case we can edit all field
- {
+ if ($caneditfield) { // Case we can edit all field
$error = 0;
if (!GETPOST("lastname", 'alpha')) {
@@ -359,8 +364,7 @@ if (empty($reshook)) {
$error++;
}
- if (!$error)
- {
+ if (!$error) {
$object->fetch($id);
$object->oldcopy = clone $object;
@@ -374,7 +378,9 @@ if (empty($reshook)) {
$object->gender = GETPOST("gender", 'aZ09');
$object->pass = GETPOST("password", 'none');
$object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
- if (!empty($user->admin)) $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
+ if (!empty($user->admin)) {
+ $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
+ }
$object->address = GETPOST('address', 'alphanohtml');
$object->zip = GETPOST('zipcode', 'alphanohtml');
$object->town = GETPOST('town', 'alphanohtml');
@@ -421,20 +427,16 @@ if (empty($reshook)) {
$object->dateendvalidity = $dateendvalidity;
$object->birth = $dateofbirth;
- if (!empty($conf->stock->enabled))
- {
+ if (!empty($conf->stock->enabled)) {
$object->fk_warehouse = GETPOST('fk_warehouse', 'int');
}
$object->lang = GETPOST('default_lang', 'aZ09');
- if (!empty($conf->multicompany->enabled))
- {
- if (!empty($_POST["superadmin"]))
- {
+ if (!empty($conf->multicompany->enabled)) {
+ if (!empty($_POST["superadmin"])) {
$object->entity = 0;
- } elseif (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
- {
+ } elseif (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$object->entity = 1; // all users in master entity
} else {
$object->entity = (!GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int'));
@@ -452,11 +454,9 @@ if (empty($reshook)) {
if (GETPOST('deletephoto')) {
$object->photo = '';
}
- if (!empty($_FILES['photo']['name']))
- {
+ if (!empty($_FILES['photo']['name'])) {
$isimage = image_format_supported($_FILES['photo']['name']);
- if ($isimage > 0)
- {
+ if ($isimage > 0) {
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
} else {
$error++;
@@ -541,8 +541,7 @@ if (empty($reshook)) {
}
}
- if (!$error && !count($object->errors))
- {
+ if (!$error && !count($object->errors)) {
// Then we add the associated categories
$categories = GETPOST('usercats', 'array');
$object->setCategories($categories);
@@ -553,8 +552,7 @@ if (empty($reshook)) {
$db->commit();
$login = $_SESSION["dol_login"];
- if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login
- {
+ if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) { // Current user has changed its login
$error++;
$langs->load("errors");
setEventMessages($langs->transnoentitiesnoconv("WarningYourLoginWasModifiedPleaseLogin"), null, 'warnings');
@@ -564,8 +562,7 @@ if (empty($reshook)) {
}
}
} else {
- if ($caneditpassword) // Case we can edit only password
- {
+ if ($caneditpassword) { // Case we can edit only password
dol_syslog("Not allowed to change fields, only password");
$object->fetch($id);
@@ -574,8 +571,7 @@ if (empty($reshook)) {
$object->oldcopy = clone $object;
$ret = $object->setPassword($user, GETPOST("password", "none"));
- if ($ret < 0)
- {
+ if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -596,8 +592,7 @@ if (empty($reshook)) {
} else {
// Succes
if ($action == 'confirm_passwordsend' && $confirm == 'yes') {
- if ($object->send_password($user, $newpassword) > 0)
- {
+ if ($object->send_password($user, $newpassword) > 0) {
setEventMessages($langs->trans("PasswordChangedAndSentTo", $object->email), null, 'mesgs');
} else {
setEventMessages($object->error, $object->errors, 'errors');
@@ -686,25 +681,24 @@ $formother = new FormOther($db);
$formcompany = new FormCompany($db);
$formadmin = new FormAdmin($db);
$formfile = new FormFile($db);
-if (!empty($conf->stock->enabled)) $formproduct = new FormProduct($db);
+if (!empty($conf->stock->enabled)) {
+ $formproduct = new FormProduct($db);
+}
llxHeader('', $langs->trans("UserCard"));
-if ($action == 'create' || $action == 'adduserldap')
-{
+if ($action == 'create' || $action == 'adduserldap') {
print load_fiche_titre($langs->trans("NewUser"), '', 'user');
print '