Search in sources :

Example 56 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class KnowledgeBaseUtil method addPortletBreadcrumbEntries.

protected static void addPortletBreadcrumbEntries(Map<String, Object> parameters, HttpServletRequest request, RenderResponse renderResponse) throws PortalException, SystemException {
    PortletURL portletURL = renderResponse.createRenderURL();
    for (Map.Entry<String, Object> entry : parameters.entrySet()) {
        Object value = entry.getValue();
        portletURL.setParameter(entry.getKey(), value.toString());
    }
    long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());
    long parentResourceClassNameId = (Long) parameters.get("parentResourceClassNameId");
    long parentResourcePrimKey = (Long) parameters.get("parentResourcePrimKey");
    String mvcPath = (String) parameters.get("mvcPath");
    if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
        PortalUtil.addPortletBreadcrumbEntry(request, themeDisplay.translate("home"), portletURL.toString());
    } else if (parentResourceClassNameId == kbFolderClassNameId) {
        KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(parentResourcePrimKey);
        addPortletBreadcrumbEntries(kbFolder.getClassNameId(), kbFolder.getParentKBFolderId(), mvcPath, request, renderResponse);
        PortalUtil.addPortletBreadcrumbEntry(request, kbFolder.getName(), portletURL.toString());
    } else {
        KBArticle kbArticle = KBArticleServiceUtil.getLatestKBArticle(parentResourcePrimKey, WorkflowConstants.STATUS_ANY);
        addPortletBreadcrumbEntries(kbArticle.getParentResourceClassNameId(), kbArticle.getParentResourcePrimKey(), mvcPath, request, renderResponse);
        PortalUtil.addPortletBreadcrumbEntry(request, kbArticle.getTitle(), portletURL.toString());
    }
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle) JSONObject(com.liferay.portal.kernel.json.JSONObject) PortletURL(javax.portlet.PortletURL) Map(java.util.Map) HashMap(java.util.HashMap) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 57 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class CalendarPortlet method addCalendar.

protected void addCalendar(PortletRequest portletRequest, Set<Calendar> calendarsSet, long classNameId, long classPK) throws PortalException, SystemException {
    CalendarResource calendarResource = CalendarResourceUtil.getCalendarResource(portletRequest, classNameId, classPK);
    if (calendarResource == null) {
        return;
    }
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    List<Calendar> calendars = CalendarLocalServiceUtil.getCalendarResourceCalendars(calendarResource.getGroupId(), calendarResource.getCalendarResourceId());
    for (Calendar calendar : calendars) {
        if (!CalendarPermission.contains(permissionChecker, calendar, ActionKeys.VIEW)) {
            continue;
        }
        calendarsSet.add(calendar);
    }
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) Calendar(com.liferay.calendar.model.Calendar) CalendarResource(com.liferay.calendar.model.CalendarResource) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 58 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class JournalArticleAssetRendererFactory method getURLAdd.

@Override
public PortletURL getURLAdd(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!JournalPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_ARTICLE)) {
        return null;
    }
    long classTypeId = GetterUtil.getLong(liferayPortletRequest.getAttribute(WebKeys.ASSET_RENDERER_FACTORY_CLASS_TYPE_ID));
    if ((classTypeId > 0) && !DDMStructurePermission.contains(themeDisplay.getPermissionChecker(), classTypeId, ActionKeys.VIEW)) {
        return null;
    }
    PortletURL portletURL = liferayPortletResponse.createRenderURL(PortletKeys.JOURNAL);
    portletURL.setParameter("struts_action", "/journal/edit_article");
    return portletURL;
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL) LiferayPortletURL(com.liferay.portal.kernel.portlet.LiferayPortletURL)

Example 59 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class MeetupsPortlet method updateMeetupsEntry.

public void updateMeetupsEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    if (!permissionChecker.isCompanyAdmin()) {
        return;
    }
    long meetupsEntryId = ParamUtil.getLong(uploadPortletRequest, "meetupsEntryId");
    String title = ParamUtil.getString(uploadPortletRequest, "title");
    String description = ParamUtil.getString(uploadPortletRequest, "description");
    int startDateMonth = ParamUtil.getInteger(uploadPortletRequest, "startDateMonth");
    int startDateDay = ParamUtil.getInteger(uploadPortletRequest, "startDateDay");
    int startDateYear = ParamUtil.getInteger(uploadPortletRequest, "startDateYear");
    int startDateHour = ParamUtil.getInteger(uploadPortletRequest, "startDateHour");
    int startDateMinute = ParamUtil.getInteger(uploadPortletRequest, "startDateMinute");
    int startDateAmPm = ParamUtil.getInteger(uploadPortletRequest, "startDateAmPm");
    if (startDateAmPm == Calendar.PM) {
        startDateHour += 12;
    }
    int endDateMonth = ParamUtil.getInteger(uploadPortletRequest, "endDateMonth");
    int endDateDay = ParamUtil.getInteger(uploadPortletRequest, "endDateDay");
    int endDateYear = ParamUtil.getInteger(uploadPortletRequest, "endDateYear");
    int endDateHour = ParamUtil.getInteger(uploadPortletRequest, "endDateHour");
    int endDateMinute = ParamUtil.getInteger(uploadPortletRequest, "endDateMinute");
    int endDateAmPm = ParamUtil.getInteger(uploadPortletRequest, "endDateAmPm");
    if (endDateAmPm == Calendar.PM) {
        endDateHour += 12;
    }
    int totalAttendees = ParamUtil.getInteger(uploadPortletRequest, "totalAttendees");
    int maxAttendees = ParamUtil.getInteger(uploadPortletRequest, "maxAttendees");
    double price = ParamUtil.getDouble(uploadPortletRequest, "price");
    File file = uploadPortletRequest.getFile("fileName");
    byte[] bytes = FileUtil.getBytes(file);
    if (meetupsEntryId <= 0) {
        MeetupsEntryLocalServiceUtil.addMeetupsEntry(themeDisplay.getUserId(), title, description, startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute, totalAttendees, maxAttendees, price, bytes);
    } else {
        MeetupsEntryLocalServiceUtil.updateMeetupsEntry(themeDisplay.getUserId(), meetupsEntryId, title, description, startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute, totalAttendees, maxAttendees, price, bytes);
    }
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) File(java.io.File)

Example 60 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class MicroblogsPortlet method updateMicroblogsEntry.

public void updateMicroblogsEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long microblogsEntryId = ParamUtil.getLong(actionRequest, "microblogsEntryId");
    String content = ParamUtil.getString(actionRequest, "content");
    int type = ParamUtil.getInteger(actionRequest, "type");
    long receiverUserId = ParamUtil.getLong(actionRequest, "receiverUserId");
    long receiverMicroblogsEntryId = ParamUtil.getLong(actionRequest, "receiverMicroblogsEntryId");
    int socialRelationType = ParamUtil.getInteger(actionRequest, "socialRelationType");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(MicroblogsEntry.class.getName(), actionRequest);
    String[] assetTagNames = getAssetTagNames(content);
    serviceContext.setAssetTagNames(assetTagNames);
    if (microblogsEntryId > 0) {
        MicroblogsEntryServiceUtil.updateMicroblogsEntry(microblogsEntryId, content, socialRelationType, serviceContext);
    } else {
        MicroblogsEntryServiceUtil.addMicroblogsEntry(themeDisplay.getUserId(), content, type, receiverUserId, receiverMicroblogsEntryId, socialRelationType, serviceContext);
    }
}
Also used : MicroblogsEntry(com.liferay.microblogs.model.MicroblogsEntry) ServiceContext(com.liferay.portal.service.ServiceContext) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Aggregations

ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)63 PermissionChecker (com.liferay.portal.security.permission.PermissionChecker)10 ServiceContext (com.liferay.portal.service.ServiceContext)7 JSONObject (com.liferay.portal.kernel.json.JSONObject)6 PortletURL (javax.portlet.PortletURL)6 PortalException (com.liferay.portal.kernel.exception.PortalException)5 User (com.liferay.portal.model.User)5 Gadget (com.liferay.opensocial.model.Gadget)4 SystemException (com.liferay.portal.kernel.exception.SystemException)4 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)4 PortletConfig (javax.portlet.PortletConfig)4 KBArticle (com.liferay.knowledgebase.model.KBArticle)3 KBFolder (com.liferay.knowledgebase.model.KBFolder)3 Role (com.liferay.portal.model.Role)3 HashMap (java.util.HashMap)3 LiferayPortletURL (com.liferay.portal.kernel.portlet.LiferayPortletURL)2 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)2 Folder (com.liferay.portal.kernel.repository.model.Folder)2 Layout (com.liferay.portal.model.Layout)2 SocialActivity (com.liferay.portlet.social.model.SocialActivity)2