diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 7e81efd0d16..d6ffb849aa8 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -111,8 +111,10 @@ UserAccountancyCode=User accounting code UserLogoff=User logout UserLogged=User logged DateOfEmployment=Employment date -DateEmployment=Employment Start Date +DateEmployment=Employment +DateEmploymentstart=Employment Start Date DateEmploymentEnd=Employment End Date +RangeOfLoginValidity=Date range of login validity CantDisableYourself=You can't disable your own user record ForceUserExpenseValidator=Force expense report validator ForceUserHolidayValidator=Force leave request validator diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1065073b13c..f13d0c33e16 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -357,7 +357,7 @@ if (!defined('NOTOKENRENEWAL')) $_SESSION['newtoken'] = $token; } -//dol_syslog("aaaa - ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha').' '.$_SESSION['token']); +dol_syslog("aaaa - ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha').' '.$_SESSION['token']); //$dolibarr_nocsrfcheck=1; // Check token if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) @@ -381,10 +381,14 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings'); //if ($conf->global->MAIN_FEATURES_LEVEL >= 1) setEventMessages('Unset POST and GET params by CSRF protection in main.inc.php (Token provided was not generated by the previous page).'."
\n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], null, 'warnings'); $savid = ((int) $_POST['id']); - unset($_POST); - $_POST['id'] = ((int) $savid); + //$savaction = preg_replace('/[^a-zA-Z0-9]/', '', $_POST['action']); + unset ($_POST); + //unset($_POST['action']); + unset($_POST['confirm']); unset($_GET['confirm']); unset($_GET['action']); + $_POST['id'] = ((int) $savid); + $_POST['action'] = ''; } } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 1a81520eec8..96b9d55af6a 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -61,6 +61,12 @@ $group = GETPOST("group", "int", 3); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search +$dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int')); +$dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); +$datestartvalidity = dol_mktime(0, 0, 0, GETPOST('datestartvaliditymonth', 'int'), GETPOST('datestartvalidityday', 'int'), GETPOST('datestartvalidityyear', 'int')); +$dateendvalidity = dol_mktime(0, 0, 0, GETPOST('dateendvaliditymonth', 'int'), GETPOST('dateendvalidityday', 'int'), GETPOST('dateendvalidityyear', 'int')); +$dateofbirth = dol_mktime(0, 0, 0, GETPOST('dateofbirthmonth', 'int'), GETPOST('dateofbirthday', 'int'), GETPOST('dateofbirthyear', 'int')); + // Define value to know what current user can do on users $canadduser = (!empty($user->admin) || $user->rights->user->user->creer); $canreaduser = (!empty($user->admin) || $user->rights->user->user->lire); @@ -202,8 +208,6 @@ if (empty($reshook)) { $object->login = GETPOST("login", 'alphanohtml'); $object->api_key = GETPOST("api_key", 'alphanohtml'); $object->gender = GETPOST("gender", 'aZ09'); - $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); - $object->birth = $birth; $object->admin = GETPOST("admin", 'int'); $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); @@ -247,11 +251,12 @@ if (empty($reshook)) { $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : ''; $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : ''; - $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int')); - $object->dateemployment = $dateemployment; - $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); + $object->dateemployment = $dateemployment; $object->dateemploymentend = $dateemploymentend; + $object->datestartvalidity = $datestartvalidity; + $object->dateendvalidity = $dateendvalidity; + $object->birth = $dateofbirth; $object->fk_warehouse = GETPOST('fk_warehouse', 'int'); @@ -364,8 +369,6 @@ if (empty($reshook)) { $object->firstname = GETPOST("firstname", 'alphanohtml'); $object->login = GETPOST("login", 'alphanohtml'); $object->gender = GETPOST("gender", 'aZ09'); - $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); - $object->birth = $birth; $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 @@ -409,10 +412,11 @@ if (empty($reshook)) { $object->weeklyhours = price2num($object->weeklyhours); $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : ''; - $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int')); $object->dateemployment = $dateemployment; - $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); $object->dateemploymentend = $dateemploymentend; + $object->datestartvalidity = $datestartvalidity; + $object->dateendvalidity = $dateendvalidity; + $object->birth = $dateofbirth; if (!empty($conf->stock->enabled)) { @@ -1229,21 +1233,29 @@ if ($action == 'create' || $action == 'adduserldap') // Date employment print ''.$langs->trans("DateEmployment").''; print ''; - print $form->selectDate(GETPOST('dateemployment'), 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0); + print $form->selectDate($dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 1); + + print ' - '; + + print $form->selectDate($dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); print ''; print "\n"; - // Date employment END - print ''.$langs->trans("DateEmploymentEnd").''; + // Date validity + print ''.$langs->trans("RangeOfLoginValidity").''; print ''; - print $form->selectDate(GETPOST('dateemploymentend'), 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); + print $form->selectDate($datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1); + + print ' - '; + + print $form->selectDate($dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0); print ''; print "\n"; // Date birth - print ''.$langs->trans("DateToBirth").''; + print ''.$langs->trans("DateOfBirth").''; print ''; - print $form->selectDate(GETPOST('birth'), 'birth', 0, 0, 1, 'createuser', 1, 0); + print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0); print ''; print "\n"; @@ -1621,24 +1633,32 @@ if ($action == 'create' || $action == 'adduserldap') print ''.$langs->trans("DateOfEmployment").''; print ''; if ($object->dateemployment) { - print ''.$langs->trans("FromDate ").''; + print ''.$langs->trans("FromDate").' '; print dol_print_date($object->dateemployment, 'day'); } - //print ''; - //print "\n"; - - // Date employment - //print ''.$langs->trans("DateEmploymentEnd").''; - //print ''; if ($object->dateemploymentend) { - print ' - '.$langs->trans("To ").''; + print ' - '.$langs->trans("To").' '; print dol_print_date($object->dateemploymentend, 'day'); } print ''; print "\n"; + // Date login validity + print ''.$langs->trans("RangeOfLoginValidity").''; + print ''; + if ($object->datestartvalidity) { + print ''.$langs->trans("FromDate").' '; + print dol_print_date($object->datestartvalidity, 'day'); + } + if ($object->dateendvalidity) { + print ' - '.$langs->trans("To").' '; + print dol_print_date($object->dateendvalidity, 'day'); + } + print ''; + print "\n"; + // Date of birth - print ''.$langs->trans("DateToBirth").''; + print ''.$langs->trans("DateOfBirth").''; print ''; print dol_print_date($object->birth, 'day'); print ''; @@ -2672,19 +2692,16 @@ if ($action == 'create' || $action == 'adduserldap') print ''; if ($caneditfield) { - print $form->selectDate(GETPOST('dateemployment') ?GETPOST('dateemployment') : $object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0); + print $form->selectDate($dateemployment ? $dateemployment : $object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 1); } else { print dol_print_date($object->dateemployment, 'day'); } - print ''; - print "\n"; - // Date employmentEnd - print ''.$langs->trans("DateEmploymentEnd").''; - print ''; + if ($dateemployment && $dateemploymentend) print ' - '; + if ($caneditfield) { - print $form->selectDate(GETPOST('dateemploymentend') ?GETPOST('dateemploymentend') : $object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); + print $form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); } else { print dol_print_date($object->dateemploymentend, 'day'); } @@ -2692,12 +2709,33 @@ if ($action == 'create' || $action == 'adduserldap') print "\n"; - // Date birth - print ''.$langs->trans("DateToBirth").''; + // Date login validity + print ''.$langs->trans("RangeOfLoginValidity").''; print ''; if ($caneditfield) { - echo $form->selectDate(GETPOST('birth') ?GETPOST('birth') : $object->birth, 'birth', 0, 0, 1, 'updateuser', 1, 0); + print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1); + } else { + print dol_print_date($object->datestartvalidity, 'day'); + } + + if ($datestartvalidity && $dateendvalidity) print ' - '; + + if ($caneditfield) + { + print $form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0); + } else { + print dol_print_date($object->dateendvalidity, 'day'); + } + print ''; + print "\n"; + + + // Date birth + print ''.$langs->trans("DateOfBirth").''; + print ''; + if ($caneditfield) { + echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0); } else { print dol_print_date($object->birth, 'day'); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index de0b73d6aec..786af8c81d1 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -154,7 +154,7 @@ class User extends CommonObject public $datelastlogin; public $datepreviouslogin; public $datestartvalidity; - public $dateedvalidity; + public $dateendvalidity; public $photo; public $lang; @@ -1467,7 +1467,6 @@ class User extends CommonObject $this->employee = $this->employee ? $this->employee : 0; $this->login = trim($this->login); $this->gender = trim($this->gender); - $this->birth = trim($this->birth); $this->pass = trim($this->pass); $this->api_key = trim($this->api_key); $this->address = $this->address ?trim($this->address) : trim($this->address); @@ -1495,6 +1494,9 @@ class User extends CommonObject $this->color = empty($this->color) ? '' : $this->color; $this->dateemployment = empty($this->dateemployment) ? '' : $this->dateemployment; $this->dateemploymentend = empty($this->dateemploymentend) ? '' : $this->dateemploymentend; + $this->datestartvalidity = empty($this->datestartvalidity) ? '' : $this->datestartvalidity; + $this->dateendvalidity = empty($this->dateendvalidity) ? '' : $this->dateendvalidity; + $this->birth = trim($this->birth); $this->fk_warehouse = trim(empty($this->fk_warehouse) ? '' : $this->fk_warehouse); // Check parameters @@ -1541,6 +1543,8 @@ class User extends CommonObject $sql .= ", color = '".$this->db->escape($this->color)."'"; $sql .= ", dateemployment=".(strval($this->dateemployment) != '' ? "'".$this->db->idate($this->dateemployment)."'" : 'null'); $sql .= ", dateemploymentend=".(strval($this->dateemploymentend) != '' ? "'".$this->db->idate($this->dateemploymentend)."'" : 'null'); + $sql .= ", datestartvalidity=".(strval($this->datestartvalidity) != '' ? "'".$this->db->idate($this->datestartvalidity)."'" : 'null'); + $sql .= ", dateendvalidity=".(strval($this->dateendvalidity) != '' ? "'".$this->db->idate($this->dateendvalidity)."'" : 'null'); $sql .= ", note = '".$this->db->escape($this->note_private)."'"; $sql .= ", note_public = '".$this->db->escape($this->note_public)."'"; $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");