本文整理汇总了Java中com.liferay.portal.service.GroupLocalServiceUtil.addUserGroups方法的典型用法代码示例。如果您正苦于以下问题:Java GroupLocalServiceUtil.addUserGroups方法的具体用法?Java GroupLocalServiceUtil.addUserGroups怎么用?Java GroupLocalServiceUtil.addUserGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.service.GroupLocalServiceUtil
的用法示例。
在下文中一共展示了GroupLocalServiceUtil.addUserGroups方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addStudentToCourse
import com.liferay.portal.service.GroupLocalServiceUtil; //导入方法依赖的package包/类
@JSONWebService
public void addStudentToCourse(long courseId,String login) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.fetchCourse(courseId);
User user = userLocalService.fetchUserByScreenName(serviceContext.getCompanyId(), login);
if(course!=null && user!=null){
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), RoleLocalServiceUtil.getRole(serviceContext.getCompanyId(), RoleConstants.SITE_MEMBER).getRoleId());
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
}
}
}
示例2: addTeacherToCourse
import com.liferay.portal.service.GroupLocalServiceUtil; //导入方法依赖的package包/类
@JSONWebService
public void addTeacherToCourse(long courseId,String login) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
User user = UserLocalServiceUtil.getUserByScreenName(serviceContext.getCompanyId(), login);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), LmsPrefsLocalServiceUtil.getLmsPrefs(serviceContext.getCompanyId()).getTeacherRole());
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
}
}
示例3: addEditorToCourse
import com.liferay.portal.service.GroupLocalServiceUtil; //导入方法依赖的package包/类
@JSONWebService
public void addEditorToCourse(long courseId,String login) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
User user = UserLocalServiceUtil.getUserByScreenName(serviceContext.getCompanyId(), login);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), LmsPrefsLocalServiceUtil.getLmsPrefs(serviceContext.getCompanyId()).getEditorRole());
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
}
}
示例4: addUserRole
import com.liferay.portal.service.GroupLocalServiceUtil; //导入方法依赖的package包/类
public void addUserRole(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{
long courseId = ParamUtil.getLong(actionRequest, "courseId", 0);
long roleId = ParamUtil.getLong(actionRequest, "roleId", 0);
// long userId = ParamUtil.getLong(actionRequest, "userId", 0);
// Multiusuario
long[] to = ParamUtil.getLongValues(actionRequest, "to");
// long[] userIds=new long[1];
// userIds[0]=ParamUtil.getLong(actionRequest, "userId");
Course course = CourseLocalServiceUtil.getCourse(courseId);
LmsPrefs prefs=LmsPrefsLocalServiceUtil.getLmsPrefs(course.getCompanyId());
Long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
Long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
for (long userId : to) {
if (!GroupLocalServiceUtil.hasUserGroup(userId, course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(userId, new long[] { course.getGroupCreatedId() });
//The application only send one mail at listener
//User user = UserLocalServiceUtil.getUser(userId);
//sendEmail(user, course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { userId }, course.getGroupCreatedId(), roleId);
if(roleId == teacherRoleId){
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupCreatedId(), Course.class.getName(),
course.getCourseId(),userId, AuditConstants.REGISTER, "COURSE_TUTOR_ADD");
}
if(roleId == editorRoleId){
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupCreatedId(), Course.class.getName(),
course.getCourseId(),userId, AuditConstants.REGISTER, "COURSE_EDITOR_ADD");
}
}
actionResponse.setRenderParameters(actionRequest.getParameterMap());
}
示例5: addStudentToCourseWithDates
import com.liferay.portal.service.GroupLocalServiceUtil; //导入方法依赖的package包/类
@JSONWebService
public void addStudentToCourseWithDates(long courseId,String login,Date allowStartDate,Date allowFinishDate) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
User user = userLocalService.getUserByScreenName(serviceContext.getCompanyId(), login);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), RoleLocalServiceUtil.getRole(serviceContext.getCompanyId(), RoleConstants.SITE_MEMBER).getRoleId());
CourseResult courseResult=courseResultLocalService.getCourseResultByCourseAndUser(courseId, user.getUserId());
if(courseResult==null)
{
courseResultLocalService.create(courseId, user.getUserId(), allowStartDate, allowFinishDate);
}
else
{
courseResult.setAllowStartDate(allowStartDate);
courseResult.setAllowFinishDate(allowFinishDate);
courseResultLocalService.updateCourseResult(courseResult);
}
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
}
}
示例6: addStudentToCourseWithDates
import com.liferay.portal.service.GroupLocalServiceUtil; //导入方法依赖的package包/类
public void addStudentToCourseWithDates(long courseId,long userId,Date allowStartDate,Date allowFinishDate) throws PortalException, SystemException
{
Course course=courseLocalService.getCourse(courseId);
;
User user = userLocalService.fetchUser(userId);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), RoleLocalServiceUtil.getRole(user.getCompanyId(), RoleConstants.SITE_MEMBER).getRoleId());
CourseResult courseResult=courseResultLocalService.getCourseResultByCourseAndUser(courseId, user.getUserId());
if(courseResult==null)
{
courseResultLocalService.create(courseId, user.getUserId(), allowStartDate, allowFinishDate);
}
else
{
courseResult.setAllowStartDate(allowStartDate);
courseResult.setAllowFinishDate(allowFinishDate);
courseResultLocalService.updateCourseResult(courseResult);
}
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), userId, AuditConstants.REGISTER, null);
}