use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class WebSession method setUser.
private void setUser(User u, Set<Right> rights) {
Long _recordingId = recordingId;
Long _roomId = roomId;
Invitation _i = i;
SOAPLogin _soap = soap;
ClientInfo _info = clientInfo;
ExtendedClientProperties _extProps = extProps;
// required to prevent session fixation
replaceSession();
if (_recordingId != null) {
recordingId = _recordingId;
}
if (_roomId != null) {
roomId = _roomId;
}
if (_i != null) {
i = _i;
}
if (_soap != null) {
soap = _soap;
}
if (_info != null) {
clientInfo = _info;
}
if (_extProps != null) {
extProps = _extProps;
}
userId = u.getId();
if (rights == null || rights.isEmpty()) {
Set<Right> r = new HashSet<>(u.getRights());
if (u.getGroupUsers() != null && !AuthLevelUtil.hasAdminLevel(r)) {
for (GroupUser gu : u.getGroupUsers()) {
if (gu.isModerator()) {
r.add(Right.GroupAdmin);
break;
}
}
}
this.rights = Collections.unmodifiableSet(r);
} else {
this.rights = Collections.unmodifiableSet(rights);
}
languageId = u.getLanguageId();
externalType = u.getExternalType();
tz = getTimeZone(u);
ISO8601FORMAT = FastDateFormat.getInstance(ISO8601_FULL_FORMAT_STRING, tz);
setLocale(LocaleHelper.getLocale(u));
sdf = FormatHelper.getDateTimeFormat(u);
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class GroupUsersPanel method update.
public void update(GroupUser grpUser) {
User u = userDao.get(grpUser.getUser().getId());
int idx = u.getGroupUsers().indexOf(grpUser);
if (idx > -1) {
u.getGroupUsers().get(idx).setModerator(grpUser.isModerator());
} else {
u.getGroupUsers().add(grpUser);
}
userDao.update(u, WebSession.getUserId());
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class UserManager method registerUserInit.
/**
* @param rights - {@link Right} to be assigned to the user
* @param login - user login
* @param password - user password
* @param lastname - user last name
* @param firstname - user first name
* @param email - user email
* @param age - user birthday
* @param street - user address street
* @param additionalname - user additional name
* @param fax - user fax
* @param zip - user zip code
* @param country - user country code
* @param town - user town
* @param languageId - language id
* @param sendWelcomeMessage - should confirmation email be sent
* @param groups - ids of user groups
* @param phone - user phone
* @param sendSMS - should SMS be sent to this user
* @param sendConfirmation - should confirmation be sent
* @param timezone - the name of the time zone
* @param forceTimeZoneCheck - should time zone be verified by user
* @param userOffers - what user offers
* @param userSearchs - what user searches
* @param showContactData - is contact data publicly visible
* @param showContactDataToContacts - is contact data visible to contacts
* @param activatedHash - activation hash
* @return {@link User} of code of error as {@link String}
* @throws NoSuchAlgorithmException in case password hashing algorithm is not found
* @throws OmException in case of any issues with provided data
*/
@Override
public Object registerUserInit(Set<Right> rights, String login, String password, String lastname, String firstname, String email, Date age, String street, String additionalname, String fax, String zip, String country, String town, long languageId, boolean sendWelcomeMessage, List<Long> groups, String phone, boolean sendSMS, Boolean sendConfirmation, TimeZone timezone, Boolean forceTimeZoneCheck, String userOffers, String userSearchs, Boolean showContactData, Boolean showContactDataToContacts, String activatedHash) throws OmException, NoSuchAlgorithmException {
// Check for required data
if (login.length() >= getMinLoginLength(cfgDao)) {
// Check for duplicates
boolean checkName = userDao.checkLogin(login, User.Type.user, null, null);
boolean checkEmail = Strings.isEmpty(email) || userDao.checkEmail(email, User.Type.user, null, null);
if (checkName && checkEmail) {
String hash = Strings.isEmpty(activatedHash) ? UUID.randomUUID().toString() : activatedHash;
if (sendWelcomeMessage && email.length() != 0) {
emailManager.sendMail(login, email, hash, sendConfirmation, languageId);
}
Address a = new Address();
a.setStreet(street);
a.setZip(zip);
a.setTown(town);
a.setCountry(country);
a.setAdditionalname(additionalname);
a.setComment("");
a.setFax(fax);
a.setPhone(phone);
a.setEmail(email);
// code then set the status to 0
if (sendConfirmation && rights.contains(Right.Login)) {
rights.remove(Right.Login);
}
User u = new User();
u.setFirstname(firstname);
u.setLogin(login);
u.setLastname(lastname);
u.setAge(age);
u.setAddress(a);
u.setSendSMS(sendSMS);
u.setRights(rights);
u.setLastlogin(new Date());
u.setSalutation(Salutation.mr);
u.setActivatehash(hash);
u.setTimeZoneId(timezone.getID());
u.setForceTimeZoneCheck(forceTimeZoneCheck);
if (!Strings.isEmpty(u.getExternalType())) {
u.setType(Type.external);
}
u.setUserOffers(userOffers);
u.setUserSearchs(userSearchs);
u.setShowContactData(showContactData);
u.setShowContactDataToContacts(showContactDataToContacts);
// this is needed cause the language is not a needed data at registering
u.setLanguageId(languageId != 0 ? languageId : 1);
if (!Strings.isEmpty(password)) {
u.updatePassword(cfgDao, password);
}
if (groups != null) {
for (Long grpId : groups) {
u.getGroupUsers().add(new GroupUser(groupDao.get(grpId), u));
}
}
u = userDao.update(u, null);
log.debug("Added user-Id " + u.getId());
if (a.getId() != null && u.getId() != null) {
return u;
}
} else {
if (!checkName) {
return "error.login.inuse";
} else {
return "error.email.inuse";
}
}
} else {
return "error.short.login";
}
return UNKNOWN.getKey();
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class GeneralUserForm method updateModelObject.
public void updateModelObject(User u, boolean isAdminForm) {
grpUsers.clear();
grpUsers.addAll(u.getGroupUsers());
if (isAdminForm) {
List<Group> grpList = hasGroupAdminLevel(getRights()) ? groupDao.get(null, getUserId(), 0, Integer.MAX_VALUE, null) : groupDao.get(0, Integer.MAX_VALUE);
for (Group g : grpList) {
GroupUser gu = new GroupUser(g, u);
int idx = grpUsers.indexOf(gu);
if (idx < 0) {
grpUsers.add(gu);
}
}
}
age = CalendarHelper.getDate(u.getAge(), u.getTimeZoneId());
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class GroupWebService method removeUser.
/**
* Remove user from a certain group
*
* @param sid
* The SID from getSession
* @param userid
* the user id
* @param id
* the group id
* @return {@link ServiceResult} with result type, and id of the user added, or error id in case of the error as text
*/
@DELETE
@Path("/{id}/users/{userid}")
public ServiceResult removeUser(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id, @PathParam("userid") @WebParam(name = "userid") Long userid) {
return performCall(sid, User.Right.Soap, sd -> {
if (groupUserDao.isUserInGroup(id, userid)) {
User u = userDao.get(userid);
for (Iterator<GroupUser> iter = u.getGroupUsers().iterator(); iter.hasNext(); ) {
GroupUser gu = iter.next();
if (id.equals(gu.getGroup().getId())) {
iter.remove();
}
}
userDao.update(u, sd.getUserId());
}
return new ServiceResult(String.valueOf(userid), Type.SUCCESS);
});
}
Aggregations