use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method getGroupsOfUser.
/**
* permet de récupérer la liste des groupes/projets d'un utilisateur #MR
*/
private void getGroupsOfUser() {
UserHelper2 userHelper = new UserHelper2();
if (user.isIsSuperAdmin()) {
// l'utilisateur est superAdmin
listeGroupsOfUser = userHelper.getAllGroups(connect.getPoolConnexion());
return;
}
listeGroupsOfUser = userHelper.getGroupsOfUser(connect.getPoolConnexion(), user.getIdUser());
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method addUserRoleOnGroup.
/**
* permet d'ajouter un role pour l'utilisateur sur ce groupe
*
* @param idUser
* @param idRole
* @param idGroup
* @return
*/
public boolean addUserRoleOnGroup(int idUser, int idRole, int idGroup) {
if (idRole > 1) {
if (idGroup == -1 || idGroup == 0) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("profile.needGroupMessage")));
return false;
}
}
UserHelper2 userHelper = new UserHelper2();
if (idRole == 1) {
// cas de changement en superAdmin
// userHelper.setIsSuperAdmin(conn, idUser, vueListSuperAdmin)
}
if (!userHelper.addUserRoleOnGroup(connect.getPoolConnexion(), idUser, idRole, idGroup)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return false;
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("profile.ModifyRoleMessage")));
nodeUserRoleGroups = userHelper.getUserRoleGroup(connect.getPoolConnexion(), idUser);
listUsersByGroup();
listSuperAdmin();
return true;
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method addNewRoleOnGroup.
public void addNewRoleOnGroup() {
UserHelper2 userHelper = new UserHelper2();
if (groupAdded == null || groupAdded.isEmpty()) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Groupe manquant")));
return;
}
int idGroup = Integer.parseInt(groupAdded);
if (!userHelper.addUserRoleOnGroup(connect.getPoolConnexion(), userSelected, roleAdded, idGroup)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return;
}
listUsersByGroup();
listAllGroupUser();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("profile.ModifyRoleMessage")));
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method getAllProject.
/**
* permet de récupérer tous les projets pour la gestion
*/
private void getAllProject() {
UserHelper2 userHelper = new UserHelper2();
nodeAllProject = userHelper.getAllProject(connect.getPoolConnexion());
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method addUserGroup.
/**
* permet de créer un groupe/projet
* @return
*/
public boolean addUserGroup() {
editPassed = false;
if (!user.isIsSuperAdmin()) {
return false;
}
if (groupAdded == null) {
return false;
}
if (groupAdded.isEmpty()) {
return false;
}
UserHelper2 userHelper = new UserHelper2();
if (userHelper.isUserGroupExist(connect.getPoolConnexion(), groupAdded)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "Ce projet existe déjà"));
return false;
}
if (!userHelper.createUserGroup(connect.getPoolConnexion(), groupAdded)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "Erreur BDD"));
return false;
}
editPassed = true;
getGroupsOfUser();
getAllProject();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", "Projet ajouté"));
PrimeFaces pf = PrimeFaces.current();
if (pf.isAjaxRequest()) {
pf.ajax().update("idAddUserGroupDlg");
}
return true;
}
Aggregations