Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Correction connexion LDAP (et consorts) (#694)
Browse files Browse the repository at this point in the history
* Utilisation de pwd2 qui n'est pas randomisé

* Compatibilité modification

* Correction star
  • Loading branch information
prytoegrian authored Sep 9, 2018
1 parent a87d686 commit 02ae3f2
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 70 deletions.
4 changes: 2 additions & 2 deletions App/Libraries/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function searchLdap($search)
private function getInfosUser($nom)
{
$data = [];
$filter = "(&(" . $this->configuration['attrNomAff'] . "=" . $nom . "*)
$filter = "(&(" . $this->configuration['attrNomAff'] . "=*" . $nom . "*)
(" . $this->configuration['attrFiltre'] . "=" . $this->configuration['filtre'] . "))";

$attributs = [$this->configuration['attrLogin'], $this->configuration['attrNom'], $this->configuration['attrPrenom']];
Expand Down Expand Up @@ -83,4 +83,4 @@ public function getEmailUser($login)

return "";
}
}
}
136 changes: 68 additions & 68 deletions App/ProtoControllers/HautResponsable/Utilisateur.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static function getFormUser($userId = NIL_INT)
$return .= \App\ProtoControllers\HautResponsable\Utilisateur::getFormUserGroupes($formValue);
$return .= '<hr>';
}

$return .= '<input class="btn btn-success" type="submit" value="' . _('form_submit') . '">';
$return .= ' <a class="btn btn-default" href="hr_index.php?onglet=page_principale">' . _('form_cancel') . '</a>';
$return .= '</form>';
Expand All @@ -317,12 +317,12 @@ public static function getFormUser($userId = NIL_INT)

/**
* formulaire de gestion des soldes d'un utilisateur
*
*
* @param array $data
* @param int $userId
*
* @return string
*
*
* @return string
*
*/
private static function getFormUserSoldes($data, $userId)
{
Expand Down Expand Up @@ -396,7 +396,7 @@ private static function getFormUserSoldes($data, $userId)

/**
* Formulaire d'affectation aux groupes pour un nouvel utilisateur
*
*
* @param array $data
* @return string
*/
Expand Down Expand Up @@ -453,7 +453,7 @@ private static function getFormUserGroupes($data)

/**
* Formulaire de confirmation de suppression d'un utilisateur
*
*
* @param string $login
* @return string
*/
Expand All @@ -466,7 +466,7 @@ public static function getFormDeleteUser($login)
$notice = '';

if (!empty($_POST)) {
$formValue =
$formValue =
[
'login' => $_POST['new_login'],
'_METHOD' => $_POST['_METHOD'],
Expand Down Expand Up @@ -525,12 +525,12 @@ public static function getFormDeleteUser($login)

/**
* Nettoyage des données postés par le formulaire
*
* @param type $htmlPost
*
* @param array $htmlPost
* @param \includes\SQL $sql
* @param \App\Libraries\Configuration $config
*
* @return type
*
* @return array
*/
public static function dataForm2Array($htmlPost, \includes\SQL $sql, \App\Libraries\Configuration $config)
{
Expand Down Expand Up @@ -559,8 +559,8 @@ public static function dataForm2Array($htmlPost, \includes\SQL $sql, \App\Librar
$data['pwd1'] = $htmlPost['new_password1'] == "" ? "" : md5($htmlPost['new_password1']);
$data['pwd2'] = $htmlPost['new_password2'] == "" ? "" : md5($htmlPost['new_password2']);
} else {
$data['pwd1'] = md5(uniqid('', true));
$data['pwd2'] = md5('none');
$data['pwd1'] = md5('none');
$data['pwd2'] = md5(uniqid('', true));
}

if (array_key_exists('_METHOD', $htmlPost)) {
Expand Down Expand Up @@ -616,7 +616,7 @@ private static function postFormUtilisateur(array $post, array &$errors, &$notic
$errors[] = _('non autorisé');
return $return;
}

if (!empty($post['_METHOD'])) {
switch ($post['_METHOD']) {
case 'DELETE':
Expand Down Expand Up @@ -648,12 +648,12 @@ private static function postFormUtilisateur(array $post, array &$errors, &$notic

/**
* Controle la conformité du formulaire de création
*
* @param aray $data
*
* @param array $data
* @param array $errors
* @param \includes\SQL $sql
* @param \App\Libraries\Configuration $config
*
*
* @return boolean
*/
private static function isFormInsertValide($data, &$errors, \includes\SQL $sql, \App\Libraries\Configuration $config)
Expand All @@ -677,7 +677,7 @@ private static function isFormInsertValide($data, &$errors, \includes\SQL $sql,

/**
* Controle la conformité du formulaire de mise à jour
*
*
* @param array $data
* @param array $errors
* @param \includes\SQL $sql
Expand All @@ -694,8 +694,8 @@ private static function isFormUpdateValide($data, &$errors, \includes\SQL $sql,
}

$groupesId = \App\ProtoControllers\Groupe::getListeId($sql);
if ('N' === $data['isResp']
&& (\App\ProtoControllers\Groupe::isResponsableGroupe($data['login'], $groupesId, $sql)
if ('N' === $data['isResp']
&& (\App\ProtoControllers\Groupe::isResponsableGroupe($data['login'], $groupesId, $sql)
|| \App\ProtoControllers\Groupe::isGrandResponsableGroupe($data['login'], $groupesId, $sql))) {
$errors[] = _('Cette utilisateur est responsable d\'au moins un groupe');
$return = false;
Expand All @@ -713,7 +713,7 @@ private static function isFormUpdateValide($data, &$errors, \includes\SQL $sql,

/**
* Controle la conformité du formulaire (création et mise à jour)
*
*
* @param array $data
* @param array $errors
* @param \includes\SQL $sql
Expand Down Expand Up @@ -787,10 +787,10 @@ public static function isFormValide($data, &$errors, \includes\SQL $sql, \App\Li

/**
* Supprime un utilisateur
*
*
* @param string $user
* @param array $errors
*
*
* @return boolean
*/
private static function deleteUtilisateur($user, &$errors)
Expand Down Expand Up @@ -837,10 +837,10 @@ private static function deleteUtilisateur($user, &$errors)

/**
* Controle la possibilité de supprimer un utilisateur
*
*
* @param string $user
* @param \includes\SQL $sql
*
*
* @return boolean
*/
public static function isDeletable($user, \includes\SQL $sql)
Expand All @@ -857,7 +857,7 @@ public static function isDeletable($user, \includes\SQL $sql)

/**
* Création d'un nouvel utilisateur
*
*
* @param array $data
* @param array $errors
* @return boolean
Expand All @@ -880,22 +880,22 @@ private static function insertUtilisateur($data, &$errors)
if ($insertInfos && $insertSoldes && $insertGroupes) {
return $sql->getPdoObj()->commit();
}

$sql->getPdoObj()->rollback();
return false;
}

private static function insertInfosUtilisateur($data, \includes\SQL $sql)
{
$req = "INSERT INTO conges_users SET
u_login='" . $data['login'] . "',
u_nom='" . $data['nom'] . "',
u_prenom='" . $data['prenom'] . "',
u_is_resp='" . $data['isResp'] . "',
u_is_admin='" . $data['isAdmin'] . "',
planning_id = 0,
u_login='" . $data['login'] . "',
u_nom='" . $data['nom'] . "',
u_prenom='" . $data['prenom'] . "',
u_is_resp='" . $data['isResp'] . "',
u_is_admin='" . $data['isAdmin'] . "',
planning_id = 0,
u_is_hr='" . $data['isHR'] . "',
u_passwd='" . $data['pwd1'] . "',
u_passwd='" . $data['pwd1'] . "',
u_quotite=" . $data['quotite'] . ",
u_email = '" . $data['email'] . "',
u_heure_solde=" . \App\Helpers\Formatter::hour2Time($data['soldeHeure']) . ",
Expand All @@ -912,8 +912,8 @@ private static function insertSoldeUtilisateur($data, \includes\SQL $sql)
foreach ($typeAbsencesConges as $typeId => $info) {
$valuesStd[] = "('" . $data['login'] . "' ,"
. $typeId . ", "
. $data['joursAn'][$typeId] . ", "
. $data['soldes'][$typeId] . ", "
. $data['joursAn'][$typeId] . ", "
. $data['soldes'][$typeId] . ", "
. $data['reliquats'][$typeId] . ")" ;
}
$req = "INSERT INTO conges_solde_user (su_login, su_abs_id, su_nb_an, su_solde, su_reliquat) VALUES " . implode(",", $valuesStd);
Expand All @@ -922,8 +922,8 @@ private static function insertSoldeUtilisateur($data, \includes\SQL $sql)
if ($config->isCongesExceptionnelsActive()) {
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
foreach ($typeAbsencesExceptionnels as $typeId => $info) {
$valuesExc[] = "('" . $data['login'] . "' ,"
. $typeId . ", 0, "
$valuesExc[] = "('" . $data['login'] . "' ,"
. $typeId . ", 0, "
. $data['soldes'][$typeId] . ", 0)" ;

}
Expand All @@ -946,7 +946,7 @@ private static function insertGroupesUtilisateur($data, \includes\SQL $sql)

/**
* Mise à jour d'un utilisateur
*
*
* @param array $data
* @param array $errors
* @return boolean
Expand Down Expand Up @@ -983,10 +983,10 @@ private static function putUtilisateur($data, &$errors)

private static function updateInfosUtilisateur($data, \includes\SQL $sql)
{
$req = 'UPDATE conges_users
$req = 'UPDATE conges_users
SET u_nom="' . $data['nom'] . '",
u_prenom="' . $data['prenom'] . '",
u_is_resp="' . $data['isResp'] . '",
u_prenom="' . $data['prenom'] . '",
u_is_resp="' . $data['isResp'] . '",
u_heure_solde='. \App\Helpers\Formatter::hour2Time($data['soldeHeure']) . ',
u_is_admin="' . $data['isAdmin'] . '",
u_is_hr="' . $data['isHR'] . '",
Expand All @@ -1001,10 +1001,10 @@ private static function updateSoldeUtilisateur($data, \includes\SQL $sql)
$config = new \App\Libraries\Configuration($sql);
$typeAbsencesConges = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges');
foreach ($typeAbsencesConges as $typeId => $info) {
$valuesStd[] = '(\'' . $data['joursAn'][$typeId] . '\', \''
. $data['soldes'][$typeId] . '\', \''
. $data['reliquats'][$typeId] . '\', "'
. $data['oldLogin'] . '", '
$valuesStd[] = '(\'' . $data['joursAn'][$typeId] . '\', \''
. $data['soldes'][$typeId] . '\', \''
. $data['reliquats'][$typeId] . '\', "'
. $data['oldLogin'] . '", '
. (int) $typeId . ')';
}
$req = 'REPLACE INTO conges_solde_user (su_nb_an, su_solde, su_reliquat, su_login, su_abs_id) VALUES ' . implode(",", $valuesStd);
Expand All @@ -1014,67 +1014,67 @@ private static function updateSoldeUtilisateur($data, \includes\SQL $sql)
if ($config->isCongesExceptionnelsActive()) {
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
foreach ($typeAbsencesExceptionnels as $typeId => $info) {
$valuesExc[] = '(0, \''
. $data['soldes'][$typeId] . '\', 0, "'
. $data['oldLogin'] . '", '
$valuesExc[] = '(0, \''
. $data['soldes'][$typeId] . '\', 0, "'
. $data['oldLogin'] . '", '
. (int) $typeId . ')';
}
$req = 'REPLACE INTO conges_solde_user (su_nb_an, su_solde, su_reliquat, su_login, su_abs_id) VALUES ' . implode(",", $valuesExc);
$returnExc = $sql->query($req);
}

return $returnStd && $returnExc;
}

private static function updateLoginUtilisateur($data, \includes\SQL $sql)
{
$req = 'UPDATE conges_echange_rtt
$req = 'UPDATE conges_echange_rtt
SET e_login="' . $data['login'] . '"
WHERE e_login="' . $data['oldLogin'] . '" ';
$sql->query($req);

// update table edition_papier
$req = 'UPDATE conges_edition_papier
SET ep_login="' . $data['login'] . '"
$req = 'UPDATE conges_edition_papier
SET ep_login="' . $data['login'] . '"
WHERE ep_login="' . $data['oldLogin'] . '" ';
$sql->query($req);

// update table groupe_grd_resp
$req = 'UPDATE conges_groupe_grd_resp
$req = 'UPDATE conges_groupe_grd_resp
SET ggr_login= "' . $data['login'] . '"
WHERE ggr_login="' . $data['oldLogin'] . '" ';
$sql->query($req);

// update table groupe_resp
$req = 'UPDATE conges_groupe_resp
SET gr_login="' . $data['login'] . '"
$req = 'UPDATE conges_groupe_resp
SET gr_login="' . $data['login'] . '"
WHERE gr_login="' . $data['oldLogin'] . '" ';
$sql->query($req);

// update table conges_groupe_users
$req = 'UPDATE conges_groupe_users
SET gu_login="' . $data['login'] . '"
$req = 'UPDATE conges_groupe_users
SET gu_login="' . $data['login'] . '"
WHERE gu_login="' . $data['oldLogin'] . '" ';
$sql->query($req);

// update table periode
$req = 'UPDATE conges_periode
SET p_login="' . $data['login'] . '"
$req = 'UPDATE conges_periode
SET p_login="' . $data['login'] . '"
WHERE p_login="' . $data['oldLogin'] . '" ';
$sql->query($req);

$req = 'UPDATE conges_solde_user
SET su_login="' . $data['login'] . '"
SET su_login="' . $data['login'] . '"
WHERE su_login="' . $data['oldLogin'] . '" ' ;
$sql->query($req);

$req = 'UPDATE heure_additionnelle
SET login="' . $data['login'] . '"
SET login="' . $data['login'] . '"
WHERE login="' . $data['oldLogin'] . '" ' ;
$sql->query($req);

$req = 'UPDATE heure_repos
SET login="' . $data['login'] . '"
SET login="' . $data['login'] . '"
WHERE login="' . $data['oldLogin'] . '" ' ;
$sql->query($req);

Expand All @@ -1087,16 +1087,16 @@ private static function updateLoginUtilisateur($data, \includes\SQL $sql)

private static function updateEmailUtilisateur($data, \includes\SQL $sql)
{
$req = 'UPDATE conges_users
SET u_email = "'. $data['email'] . '"
$req = 'UPDATE conges_users
SET u_email = "'. $data['email'] . '"
WHERE u_login="' . $data['oldLogin'] . '"' ;
return $sql->query($req);
}

private static function updatePasswordUtilisateur($data, \includes\SQL $sql)
{
$req = 'UPDATE conges_users
SET u_passwd = "' . $data['pwd1'] . '"
$req = 'UPDATE conges_users
SET u_passwd = "' . $data['pwd1'] . '"
WHERE u_login="' . $data['oldLogin'] . '"' ;
return $sql->query($req);
}
Expand Down

0 comments on commit 02ae3f2

Please sign in to comment.