use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method updateUser.
/**
* permet de mettre les préférences d'un utilisateur (alertes, activé ..
*/
public void updateUser() {
UserHelper2 userHelper = new UserHelper2();
// boolean isSuperAdmin = false;
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
/* if (roleAdded == 1) {
isSuperAdmin = true;
// on supprime les roles sur les groupes
if (!userHelper.deleteRolesOfUser(conn, userEdit.getIdUser())) {
conn.rollback();
conn.close();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return;
}
}*/
if (!userHelper.updateUser(conn, userEdit.getIdUser(), userEdit.isIsActive(), userEdit.isIsAlertMail())) {
conn.rollback();
conn.close();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return;
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(CurrentUser2.class.getName()).log(Level.SEVERE, null, ex);
return;
}
roleAdded = -1;
listUsersByGroup();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info4")));
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method updateMail.
/**
* permet de changer l'adress mail de l'utilisateur
*/
public void updateMail() {
if (mailAdded == null || mailAdded.equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error6")));
} else if (!mailAdded.contains("@") || mailAdded.lastIndexOf(".") < mailAdded.indexOf("@")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error7")));
} else if (new UserHelper2().isUserMailExist(connect.getPoolConnexion(), mailAdded)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error8")));
} else {
new UserHelper2().updateMail(connect.getPoolConnexion(), user.getIdUser(), mailAdded);
user.setMail(mailAdded);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info5")));
}
mailAdded = "";
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method delUserRoleOnGroup.
/**
* permet de supprimer le role de l'utilisateur sur ce groupe
*
* @param idUser
* @param idGroup
*/
public void delUserRoleOnGroup(int idUser, int idGroup) {
UserHelper2 userHelper = new UserHelper2();
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
if (!userHelper.deleteRoleOnGroup(conn, idUser, idGroup)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
conn.commit();
conn.close();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("profile.deleteRoleMessage")));
nodeUserRoleGroups = userHelper.getUserRoleGroup(connect.getPoolConnexion(), idUser);
listUsersByGroup();
listAllGroupUser();
} catch (SQLException ex) {
Logger.getLogger(CurrentUser2.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method updateUserRoleOnGroup.
/**
* permet de modifier le role d'un utilisateur sur un groupe
*
* @param idUser
* @param idRole
* @param idGroup
*/
public void updateUserRoleOnGroup(int idUser, int idRole, int idGroup) {
if (idGroup == -1 || idGroup == 0) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("profile.needGroupMessage")));
return;
}
UserHelper2 userHelper = new UserHelper2();
if (!userHelper.updateUserRoleOnGroup(connect.getPoolConnexion(), idUser, idRole, idGroup)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return;
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("profile.ModifyRoleMessage")));
nodeUserRoleGroups = userHelper.getUserRoleGroup(connect.getPoolConnexion(), idUser);
listUsersByGroup();
listAllGroupUser();
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method renameUserGroup.
// //////////////////////////////////////////////////////////////////
// ////// fonctions pour la gestion des projets/groupes /////////////
// //////////////////////////////////////////////////////////////////
/**
* permet de renommer un groupe/projet
* @return
*/
public boolean renameUserGroup() {
editPassed = false;
if (!user.isIsSuperAdmin()) {
return false;
}
if (nodeUserGroupEdit == null) {
return false;
}
if (nodeUserGroupEdit.getGroupName().isEmpty()) {
return false;
}
UserHelper2 userHelper = new UserHelper2();
if (userHelper.isUserGroupExist(connect.getPoolConnexion(), nodeUserGroupEdit.getGroupName().trim())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "Ce projet existe déjà"));
return false;
}
if (!userHelper.updateProject(connect.getPoolConnexion(), nodeUserGroupEdit.getGroupName(), nodeUserGroupEdit.getIdGroup())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Modification refusée: ", nodeUserGroupEdit.getGroupName()));
} else {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Modification réussie: ", nodeUserGroupEdit.getGroupName()));
}
editPassed = true;
getGroupsOfUser();
getAllProject();
PrimeFaces pf = PrimeFaces.current();
if (pf.isAjaxRequest()) {
pf.ajax().update("idEditUserGroupDlg");
}
return true;
}
Aggregations