Verified Commit 349bb96f authored by Damien's avatar Damien

FEAT #10311 TIME 3:00 Remove users enabled column

parent e07737e9
......@@ -25,12 +25,6 @@ $req = new request();
$select = array();
$select[$_SESSION['tablename']['users']]= array('lastname', 'firstname', 'user_id');
if(isset($_GET['getDisableUser'])){
$enabledUser = "";
} else {
$enabledUser = "and enabled = 'Y'";
}
$where = " (lower(lastname) like lower(:input) "
."or lower(firstname) like lower(:input) "
."or user_id like :input) and (status = 'OK' or status = 'ABS') " . $enabledUser;
......
......@@ -130,7 +130,7 @@ class security extends Database
}
if (isset($user)) {
if ($user->__get('enabled') == 'Y') {
if ($user->__get('status') != 'SPD') {
$ugc = new usergroups_controler();
$sec_controler = new SecurityControler();
$serv_controler = new ServiceControler();
......
......@@ -114,7 +114,7 @@ abstract class diffusion_list_Abstract extends functions
."and l.item_type = 'user_id' "
.'and l.object_type = ? '
.'and l.object_id = ? '
."and u.enabled = 'Y' "
."and u.status != 'SPD' "
."and u.status != 'DEL' "
.'ORDER BY l.sequence',
array($item_mode, $objectType, $objectId)
......
......@@ -229,7 +229,7 @@ if (isset($_GET['what_services'])
. " e.enabled = 'Y' and ue.primary_entity='Y' " . $user_expr . $entity_expr
. " order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc limit 50";*/
$where = "u.status <> 'DEL' and u.enabled = 'Y' and"
$where = "u.status <> 'DEL' and u.status != 'SPD' and"
.' e.entity_id = ue.entity_id and u.user_id = ue.user_id and'
." e.enabled = 'Y' and ue.primary_entity='Y' ".$user_expr.$entity_expr;
$order = 'order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc';
......@@ -272,7 +272,7 @@ $entity_query =
."e.enabled = 'Y' ".$user_expr.$entity_expr
.' group by e.entity_id, e.entity_label order by e.entity_label asc limit 50';
$where = "u.status <> 'DEL' and u.enabled = 'Y'".'and e.entity_id = ue.entity_id and u.user_id = ue.user_id and '
$where = "u.status <> 'DEL' and u.status != 'SPD'".'and e.entity_id = ue.entity_id and u.user_id = ue.user_id and '
."e.enabled = 'Y' ".$user_expr.$entity_expr;
$order = 'ORDER by entity_label ASC';
$entity_query = $db->limit_select(
......
......@@ -51,7 +51,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module,
}
$users = array();
if (!empty($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['users_entities'])) {
$stmt = $db->query("select distinct ue.user_id, u.lastname, u.firstname from ".ENT_USERS_ENTITIES." ue, ".$_SESSION['tablename']['users']." u where ue.entity_id in (".$_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['users_entities'].") and u.user_id = ue.user_id and (u.status = 'OK' or u.status = 'ABS') and enabled = 'Y' order by u.lastname asc");
$stmt = $db->query("select distinct ue.user_id, u.lastname, u.firstname from ".ENT_USERS_ENTITIES." ue, ".$_SESSION['tablename']['users']." u where ue.entity_id in (".$_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']][$id_action]['users_entities'].") and u.user_id = ue.user_id and (u.status = 'OK' or u.status = 'ABS') order by u.lastname asc");
while ($res = $stmt->fetchObject()) {
array_push($users, array( 'ID' => $res->user_id, 'NOM' => functions::show_string($res->lastname), "PRENOM" => functions::show_string($res->firstname)));
}
......
......@@ -117,7 +117,7 @@ while ($state != 'END') {
$db = new Database();
$query = 'SELECT param_value_int FROM parameters WHERE id = ?';
$stmt = $db -> query($query, array('user_quota'));
if (($recipient->enabled == 'N' AND $stmt -> fetchColumn() == 0) || $recipient->status == 'DEL') {
if (($recipient->status == 'SPD' AND $stmt -> fetchColumn() == 0) || $recipient->status == 'DEL') {
$logger->write($user_id.' is disabled or deleted, this notification will not be send', 'INFO');
unset($recipients[$i]);
continue;
......
......@@ -126,6 +126,8 @@ abstract class admin_reports_Abstract extends Database
//$_SESSION['user']['reports'] = array();
require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."usergroups_controler.php");
$usergroups_controler = new usergroups_controler();
foreach(array_keys($enabled_reports)as $key)
{
$stmt = $db->query("select group_id from ".$_SESSION['tablename']['usergroups_reports']." where report_id = ? ", array($key));
......@@ -133,7 +135,7 @@ abstract class admin_reports_Abstract extends Database
$res = false;
while($res=$stmt->fetchObject())
{
if(usergroups_controler::inGroup($user_id, $res->group_id) == true)
if($usergroups_controler->inGroup($user_id, $res->group_id) == true)
{
$find = true;
break;
......
......@@ -27,7 +27,7 @@ $subQuery = array();
$subQuery[1] = "SELECT UPPER(lastname) || ' ' || firstname || ' (' || mail || ')' AS result, "
. ' %d AS confidence, mail AS email '
. "FROM users"
. " WHERE enabled ='Y' AND "
. " WHERE status != 'SPD' AND "
. "(LOWER(lastname) LIKE LOWER('%s') OR LOWER(firstname) LIKE LOWER('%s') OR LOWER(user_id) LIKE LOWER('%s') OR LOWER(user_id) LIKE LOWER('%s') OR LOWER(user_id) LIKE LOWER('%s') OR LOWER(user_id) LIKE LOWER('%s') OR LOWER(mail) LIKE LOWER('%s'))";
$subQuery[2]=
......
......@@ -516,7 +516,7 @@ abstract class visa_Abstract extends Database
users_entities.primary_entity = 'Y' and users.user_id = usergroup_content.user_id AND entities.entity_id = users_entities.entity_id AND group_id IN
(SELECT group_id FROM usergroups_services WHERE service_id = ? AND group_id = ?) order by users.lastname", array('visa_documents', $group_id));
} else {
$stmt = $db->query("SELECT distinct on(users.user_id) users.user_id, users.firstname, users.lastname, usergroup_content.group_id,entities.entity_id, users.enabled from users, usergroup_content, users_entities,entities WHERE users_entities.user_id = users.user_id and users.status <> 'DEL' and
$stmt = $db->query("SELECT distinct on(users.user_id) users.user_id, users.firstname, users.lastname, usergroup_content.group_id,entities.entity_id from users, usergroup_content, users_entities,entities WHERE users_entities.user_id = users.user_id and users.status <> 'DEL' and
users_entities.primary_entity = 'Y' and users.user_id = usergroup_content.user_id AND entities.entity_id = users_entities.entity_id AND group_id IN
(SELECT group_id FROM usergroups_services WHERE service_id = ?)
order by users.user_id,users.lastname", array('visa_documents'));
......@@ -525,7 +525,7 @@ abstract class visa_Abstract extends Database
$tab_users = array();
while ($res = $stmt->fetchObject()) {
array_push($tab_users, array('id' => $res->user_id, 'firstname' => $res->firstname, 'lastname' => $res->lastname, 'group_id' => $res->group_id, 'entity_id' => $res->entity_id, 'enabled' => $res->enabled));
array_push($tab_users, array('id' => $res->user_id, 'firstname' => $res->firstname, 'lastname' => $res->lastname, 'group_id' => $res->group_id, 'entity_id' => $res->entity_id));
}
return $tab_users;
......
......@@ -6,3 +6,6 @@
-- --
-- *************************************************************************--
UPDATE parameters SET param_value_string = '19.10.1' WHERE id = 'database_version';
UPDATE users SET status = 'SPD' WHERE enabled = 'N' and status = 'OK';
ALTER TABLE users DROP COLUMN IF EXISTS enabled;
......@@ -56,7 +56,7 @@ class UserController
if ($GLOBALS['userId'] == 'superadmin') {
$users = UserModel::get([
'select' => ['id', 'user_id', 'firstname', 'lastname', 'status', 'enabled', 'mail'],
'select' => ['id', 'user_id', 'firstname', 'lastname', 'status', 'mail'],
'where' => ['user_id != ?', 'status != ?'],
'data' => ['superadmin', 'DEL']
]);
......@@ -65,12 +65,12 @@ class UserController
$users = [];
if (!empty($entities)) {
$users = UserEntityModel::getWithUsers([
'select' => ['DISTINCT users.id', 'users.user_id', 'firstname', 'lastname', 'status', 'enabled', 'mail'],
'select' => ['DISTINCT users.id', 'users.user_id', 'firstname', 'lastname', 'status', 'mail'],
'where' => ['users_entities.entity_id in (?)', 'status != ?'],
'data' => [$entities, 'DEL']
]);
}
$usersNoEntities = UserEntityModel::getUsersWithoutEntities(['select' => ['id', 'users.user_id', 'firstname', 'lastname', 'status', 'enabled', 'mail']]);
$usersNoEntities = UserEntityModel::getUsersWithoutEntities(['select' => ['id', 'users.user_id', 'firstname', 'lastname', 'status', 'mail']]);
$users = array_merge($users, $usersNoEntities);
}
......@@ -82,8 +82,8 @@ class UserController
$quota = [];
$userQuota = ParameterModel::getById(['id' => 'user_quota', 'select' => ['param_value_int']]);
if (!empty($userQuota['param_value_int'])) {
$activeUser = UserModel::get(['select' => ['count(1)'], 'where' => ['enabled = ?', 'status = ?', 'user_id <> ?'], 'data' => ['Y', 'OK','superadmin']]);
$inactiveUser = UserModel::get(['select' => ['count(1)'], 'where' => ['enabled = ?', 'status = ?', 'user_id <> ?'], 'data' => ['N', 'OK','superadmin']]);
$activeUser = UserModel::get(['select' => ['count(1)'], 'where' => ['status = ?', 'user_id <> ?'], 'data' => ['OK','superadmin']]);
$inactiveUser = UserModel::get(['select' => ['count(1)'], 'where' => ['status = ?', 'user_id <> ?'], 'data' => ['SPD','superadmin']]);
$quota = ['actives' => $activeUser[0]['count'], 'inactives' => $inactiveUser[0]['count'], 'userQuota' => $userQuota['param_value_int']];
}
......@@ -97,7 +97,7 @@ class UserController
return $response->withStatus($error['status'])->withJson(['errors' => $error['error']]);
}
$user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['id', 'user_id', 'firstname', 'lastname', 'status', 'enabled', 'phone', 'mail', 'initials', 'loginmode', 'external_id']]);
$user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['id', 'user_id', 'firstname', 'lastname', 'status', 'phone', 'mail', 'initials', 'loginmode', 'external_id']]);
$user['external_id'] = json_decode($user['external_id'], true);
$user['signatures'] = UserSignatureModel::getByUserSerialId(['userSerialid' => $aArgs['id']]);
$user['emailSignatures'] = UserModel::getEmailSignaturesById(['userId' => $user['user_id']]);
......@@ -148,10 +148,9 @@ class UserController
$existingUser = UserModel::getByLowerLogin(['login' => $data['userId'], 'select' => ['id', 'status']]);
if (!empty($existingUser) && $existingUser['status'] == 'DEL') {
UserModel::updateStatus(['id' => $existingUser['id'], 'status' => 'OK']);
UserModel::update([
'set' => [
'enabled' => 'Y'
'status' => 'OK'
],
'where' => ['id = ?'],
'data' => [$existingUser['id']]
......@@ -180,7 +179,7 @@ class UserController
$userQuota = ParameterModel::getById(['id' => 'user_quota', 'select' => ['param_value_int']]);
if (!empty($userQuota['param_value_int'])) {
$activeUser = UserModel::get(['select' => ['count(1)'], 'where' => ['enabled = ?', 'status = ?', 'user_id <> ?'], 'data' => ['Y', 'OK','superadmin']]);
$activeUser = UserModel::get(['select' => ['count(1)'], 'where' => ['status = ?', 'user_id <> ?'], 'data' => ['OK', 'superadmin']]);
if ($activeUser[0]['count'] > $userQuota['param_value_int']) {
NotificationsEventsController::fillEventStack(['eventId' => 'user_quota', 'tableName' => 'users', 'recordId' => 'quota_exceed', 'userId' => 'superadmin', 'info' => _QUOTA_EXCEEDED]);
}
......@@ -222,25 +221,29 @@ class UserController
'initials' => $data['initials'],
'loginmode' => empty($data['loginmode']) ? 'standard' : $data['loginmode'],
];
if (!empty($data['enabled']) && $data['enabled'] == 'Y') {
$set['enabled'] = 'Y';
if (!empty($data['status']) && $data['status'] == 'OK') {
$set['status'] = 'OK';
}
if ($set['loginmode'] == 'restMode') {
$set['change_password']= 'N';
}
$userQuota = ParameterModel::getById(['id' => 'user_quota', 'select' => ['param_value_int']]);
$user = [];
if (!empty($userQuota['param_value_int'])) {
$user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['status']]);
}
UserModel::update([
'set' => $set,
'where' => ['id = ?'],
'data' => [$aArgs['id']]
]);
$userQuota = ParameterModel::getById(['id' => 'user_quota', 'select' => ['param_value_int']]);
if (!empty($userQuota['param_value_int'])) {
$user = UserModel::getById(['id' => $aArgs['id'], 'select' => ['enabled']]);
if ($user['enabled'] == 'N' && $data['enabled'] == 'Y') {
$activeUser = UserModel::get(['select' => ['count(1)'], 'where' => ['enabled = ?', 'status = ?', 'user_id != ?'], 'data' => ['Y', 'OK', 'superadmin']]);
if ($user['status'] == 'SPD' && $data['status'] == 'OK') {
$activeUser = UserModel::get(['select' => ['count(1)'], 'where' => ['status = ?', 'user_id != ?'], 'data' => ['OK', 'superadmin']]);
if ($activeUser[0]['count'] > $userQuota['param_value_int']) {
NotificationsEventsController::fillEventStack(['eventId' => 'user_quota', 'tableName' => 'users', 'recordId' => 'quota_exceed', 'userId' => 'superadmin', 'info' => _QUOTA_EXCEEDED]);
}
......@@ -369,7 +372,7 @@ class UserController
UserModel::update([
'set' => [
'enabled' => 'N'
'status' => 'SPD'
],
'where' => ['id = ?'],
'data' => [$aArgs['id']]
......
......@@ -73,7 +73,6 @@ abstract class UserModelAbstract
'mail' => $aArgs['user']['mail'],
'phone' => $aArgs['user']['phone'],
'initials' => $aArgs['user']['initials'],
'enabled' => 'Y',
'status' => 'OK',
'change_password' => empty($aArgs['user']['changePassword']) ? 'Y' : $aArgs['user']['changePassword'],
'loginmode' => empty($aArgs['user']['loginmode']) ? 'standard' : $aArgs['user']['loginmode'],
......
......@@ -86,8 +86,8 @@ class AutoCompleteController
$requestData = AutoCompleteController::getDataForRequest([
'search' => $data['search'],
'fields' => '(firstname ilike ? OR lastname ilike ?)',
'where' => ['enabled = ?', 'status != ?', 'user_id not in (?)'],
'data' => ['Y', 'DEL', $excludedUsers],
'where' => ['status not in (?)', 'user_id not in (?)'],
'data' => [['DEL', 'SPD'], $excludedUsers],
'fieldsNumber' => 2,
]);
......@@ -163,8 +163,8 @@ class AutoCompleteController
$requestData = AutoCompleteController::getDataForRequest([
'search' => $data['search'],
'fields' => '(firstname ilike ? OR lastname ilike ?)',
'where' => ['enabled = ?', 'status != ?', 'user_id not in (?)'],
'data' => ['Y', 'DEL', $excludedUsers],
'where' => ['status not in (?)', 'user_id not in (?)'],
'data' => [['DEL', 'SPD'], $excludedUsers],
'fieldsNumber' => 2,
]);
......@@ -207,10 +207,9 @@ class AutoCompleteController
'where' => [
'users.user_id = users_entities.user_id',
'users_entities.entity_id in (?)',
'users.status != ?',
'users.enabled = ?'
'users.status not in (?)'
],
'data' => [$entities, 'DEL', 'Y'],
'data' => [$entities, ['DEL', 'SPD']],
'fieldsNumber' => 2,
]);
......@@ -229,10 +228,9 @@ class AutoCompleteController
'where' => [
'users_entities IS NULL',
'users.user_id not in (?)',
'users.status != ?',
'users.enabled = ?'
'users.status not in (?)'
],
'data' => [$excludedUsers, 'DEL', 'Y'],
'data' => [$excludedUsers, ['DEL', 'SPD']],
'fieldsNumber' => 2,
]);
......@@ -251,8 +249,8 @@ class AutoCompleteController
$requestData = AutoCompleteController::getDataForRequest([
'search' => $data['search'],
'fields' => '(firstname ilike ? OR lastname ilike ?)',
'where' => ['enabled = ?', 'status != ?', 'user_id not in (?)'],
'data' => ['Y', 'DEL', $excludedUsers],
'where' => ['status not in (?)', 'user_id not in (?)'],
'data' => [['DEL', 'SPD'], $excludedUsers],
'fieldsNumber' => 2,
]);
......@@ -296,10 +294,9 @@ class AutoCompleteController
'usergroup_content.user_id = users.user_id',
'usergroups_services.service_id in (?)',
'users.user_id not in (?)',
'users.enabled = ?',
'users.status != ?'
'users.status not in (?)'
],
'data' => [['visa_documents', 'sign_document'], $excludedUsers, 'Y', 'DEL'],
'data' => [['visa_documents', 'sign_document'], $excludedUsers, ['DEL', 'SPD']],
'fieldsNumber' => 2,
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment