use of org.olat.course.groupsandrights.CourseGroupManager in project OpenOLAT by OpenOLAT.
the class MembersMailController method doSend.
private void doSend(UserRequest ureq) {
ContactList contactList = new ContactList("");
if (courseEnv == null) {
if (coachEl != null && coachEl.isAtLeastSelected(1)) {
List<Long> identityKeys = new ArrayList<>(coachList.size());
for (Member coach : coachList) {
identityKeys.add(coach.getKey());
}
List<Identity> coaches = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(coaches);
}
if (participantEl != null && participantEl.isAtLeastSelected(1)) {
List<Long> identityKeys = new ArrayList<>(participantList.size());
for (Member participant : participantList) {
identityKeys.add(participant.getKey());
}
List<Identity> participants = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(participants);
}
if (waitingEl != null && waitingEl.isAtLeastSelected(1)) {
List<Long> identityKeys = new ArrayList<>(waitingList.size());
for (Member waiter : waitingList) {
identityKeys.add(waiter.getKey());
}
List<Identity> waiters = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(waiters);
}
} else {
if (ownerEl != null && ownerEl.isAtLeastSelected(1)) {
RepositoryEntry courseRepositoryEntry = courseEnv.getCourseGroupManager().getCourseEntry();
List<Identity> owners = repositoryService.getMembers(courseRepositoryEntry, GroupRoles.owner.name());
contactList.addAllIdentites(owners);
}
if (coachEl != null && coachEl.isAtLeastSelected(1)) {
Set<Long> sendToWhatYouSee = new HashSet<>();
for (Member coach : coachList) {
sendToWhatYouSee.add(coach.getKey());
}
CourseGroupManager cgm = courseEnv.getCourseGroupManager();
avoidInvisibleMember(cgm.getCoachesFromBusinessGroups(), contactList, sendToWhatYouSee);
avoidInvisibleMember(cgm.getCoaches(), contactList, sendToWhatYouSee);
}
if (participantEl != null && participantEl.isAtLeastSelected(1)) {
Set<Long> sendToWhatYouSee = new HashSet<>();
for (Member participant : participantList) {
sendToWhatYouSee.add(participant.getKey());
}
CourseGroupManager cgm = courseEnv.getCourseGroupManager();
avoidInvisibleMember(cgm.getParticipantsFromBusinessGroups(), contactList, sendToWhatYouSee);
avoidInvisibleMember(cgm.getParticipants(), contactList, sendToWhatYouSee);
}
}
if (individualEl != null && individualEl.isAtLeastSelected(1) && selectedMembers != null && selectedMembers.size() > 0) {
List<Long> identityKeys = new ArrayList<>(selectedMembers.size());
for (Member member : selectedMembers) {
identityKeys.add(member.getKey());
}
List<Identity> selectedIdentities = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(selectedIdentities);
}
if (externalEl != null && externalEl.isAtLeastSelected(1)) {
String value = externalAddressesEl.getValue();
if (StringHelper.containsNonWhitespace(value)) {
for (StringTokenizer tokenizer = new StringTokenizer(value, ",\r\n", false); tokenizer.hasMoreTokens(); ) {
String email = tokenizer.nextToken().trim();
contactList.add(new EMailIdentity(email, getLocale()));
}
}
}
doSendEmailToMember(ureq, contactList);
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
the class InLearningGroupFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.groupname"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.groupname"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.groupnameexpected", "solution.example.name.infunction"));
String groupName = (String) inStack[0];
groupName = groupName != null ? groupName.trim() : null;
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsGroup(groupName)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, groupName, "error.notfound.name", "solution.checkgroupmanagement"));
}
// remember the reference to the node id for this condtion
cev.addSoftReference("groupId", groupName, false);
// return a valid value to continue with condition evaluation test
return defaultValue();
}
// the real function evaluation which is used during run time
if (StringHelper.isLong(groupName)) {
try {
Long groupKey = Long.parseLong(groupName);
return getUserCourseEnv().isIdentityInCourseGroup(groupKey) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
} catch (NumberFormatException e) {
log.error("" + groupName, e);
}
}
CourseGroupManager cgm = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager();
List<Long> groupKeys = CoreSpringFactory.getImpl(BusinessGroupService.class).toGroupKeys(groupName, cgm.getCourseEntry());
if (!groupKeys.isEmpty()) {
Identity ident = getUserCourseEnv().getIdentityEnvironment().getIdentity();
return cgm.isIdentityInGroup(ident, groupKeys.get(0)) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
return ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
the class InRightGroupFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.groupname"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.groupname"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.groupnameexpected", "solution.example.name.infunction"));
String groupName = (String) inStack[0];
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsGroup(groupName)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, groupName, "error.notfound.name", "solution.checkgroupmanagement"));
}
// remember the reference to the node id for this condition
cev.addSoftReference("groupId", groupName, false);
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
Identity ident = getUserCourseEnv().getIdentityEnvironment().getIdentity();
CourseGroupManager cgm = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager();
if (StringHelper.isLong(groupName)) {
Long groupKey = new Long(groupName);
return cgm.isIdentityInGroup(ident, groupKey) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
// TODO gm
List<Long> groupKeys = CoreSpringFactory.getImpl(BusinessGroupService.class).toGroupKeys(groupName, cgm.getCourseEntry());
if (!groupKeys.isEmpty()) {
return cgm.isIdentityInGroup(ident, groupKeys.get(0)) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
return ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
the class IsLearningGroupFullFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.groupname"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.groupname"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.groupnameexpected", "solution.example.name.infunction"));
String groupName = (String) inStack[0];
groupName = groupName != null ? groupName.trim() : null;
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsGroup(groupName)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, groupName, "error.notfound.name", "solution.checkgroupmanagement"));
}
// remember the reference to the node id for this condition
cev.addSoftReference("groupId", groupName, false);
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
CourseGroupManager cgm = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager();
if (StringHelper.isLong(groupName)) {
Long groupKey = new Long(groupName);
return cgm.isBusinessGroupFull(groupKey) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
List<Long> groupKeys = CoreSpringFactory.getImpl(BusinessGroupService.class).toGroupKeys(groupName, cgm.getCourseEntry());
if (!groupKeys.isEmpty()) {
return cgm.isBusinessGroupFull(groupKeys.get(0)) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
return ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.groupsandrights.CourseGroupManager in project openolat by klemens.
the class SPRunController method hasEditRights.
private boolean hasEditRights(UserRequest ureq) {
if (userCourseEnv.isCourseReadOnly())
return false;
if (fileName != null && fileName.startsWith("/_sharedfolder")) {
if (userCourseEnv.getCourseEnvironment().getCourseConfig().isSharedFolderReadOnlyMount()) {
return false;
}
}
if (isFileTypeEditable(fileName)) {
Roles roles = ureq.getUserSession().getRoles();
if (roles.isOLATAdmin()) {
return true;
}
CourseGroupManager cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
if (roles.isInstitutionalResourceManager() && repositoryManager.isInstitutionalRessourceManagerFor(getIdentity(), roles, cgm.getCourseEntry())) {
return true;
}
if (config.getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_COACH_EDIT, false)) {
if (cgm.isIdentityCourseCoach(ureq.getIdentity())) {
return true;
}
}
return cgm.isIdentityCourseAdministrator(getIdentity()) || cgm.hasRight(getIdentity(), CourseRights.RIGHT_COURSEEDITOR);
}
return false;
}
Aggregations