Example usage for com.liferay.portal.kernel.util PortletKeys FLAGS

List of usage examples for com.liferay.portal.kernel.util PortletKeys FLAGS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PortletKeys FLAGS.

Prototype

String FLAGS

To view the source code for com.liferay.portal.kernel.util PortletKeys FLAGS.

Click Source Link

Usage

From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java

License:Open Source License

protected void notify(long reporterUserId, Company company, Group group, String reporterEmailAddress,
        String reporterUserName, String reportedEmailAddress, String reportedUserName, String reportedUserURL,
        long contentId, String contentTitle, String contentType, String contentURL, String reason,
        String fromName, String fromAddress, String toName, String toAddress, String subject, String body,
        ServiceContext serviceContext) throws Exception {

    Date now = new Date();

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(body);//from  www  . j  a v  a 2  s  . co m
    subscriptionSender.setCompanyId(company.getCompanyId());
    subscriptionSender.setContextAttributes("[$CONTENT_ID$]", contentId, "[$CONTENT_TYPE$]", contentType,
            "[$DATE$]", now.toString(), "[$REASON$]", reason, "[$REPORTED_USER_ADDRESS$]", reportedEmailAddress,
            "[$REPORTED_USER_NAME$]", reportedUserName, "[$REPORTED_USER_URL$]", reportedUserURL,
            "[$REPORTER_USER_ADDRESS$]", reporterEmailAddress, "[$REPORTER_USER_NAME$]", reporterUserName);
    subscriptionSender.setContextAttribute("[$CONTENT_TITLE$]", contentTitle, false);
    subscriptionSender.setContextAttribute("[$CONTENT_URL$]", contentURL, false);
    subscriptionSender.setCreatorUserId(reporterUserId);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedContextAttributeWithFunction("[$SITE_NAME$]",
            locale -> _getGroupDescriptiveName(group, locale));
    subscriptionSender.setMailId("flags_request", contentId);
    subscriptionSender.setPortletId(PortletKeys.FLAGS);
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);

    subscriptionSender.addRuntimeSubscribers(toAddress, toName);

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java

License:Open Source License

@Override
public int doStartTag() {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String randomNamespace = StringUtil.randomId() + StringPool.UNDERLINE;

    try {//  w w w.j  a  va2s .  c o  m
        Map<String, Object> context = getContext();

        boolean enabled = GetterUtil.getBoolean(context.get("enabled"), true);

        Company company = themeDisplay.getCompany();

        putValue("companyName", company.getName());

        putValue("flagsEnabled", _isFlagsEnabled(themeDisplay));

        putValue("formData", _getDataJSONObject(context));

        putValue("id", randomNamespace + "id");

        putValue("enabled", enabled);

        boolean label = GetterUtil.getBoolean(context.get("label"), true);

        putValue("label", label);

        String message = GetterUtil.getString(context.get("message"), LanguageUtil.get(request, "flag"));

        putValue("message", message);

        putValue("pathTermsOfUse", themeDisplay.getPathMain() + "/portal/terms_of_use");

        putValue("pathThemeImages", themeDisplay.getPathThemeImages());

        putValue("portletNamespace", PortalUtil.getPortletNamespace(PortletKeys.FLAGS));

        boolean signedIn = themeDisplay.isSignedIn();

        putValue("signedIn", signedIn);

        if (signedIn) {
            User user = themeDisplay.getUser();

            putValue("reporterEmailAddress", user.getEmailAddress());
        }

        String title = message;

        if (!enabled) {
            title = LanguageUtil.get(request,
                    "flags-are-disabled-because-this-entry-is-in-the-recycle-" + "bin");
        }

        putValue("title", title);

        putValue("uri", _getURI());

        putValue("reasons", _getReasons(themeDisplay.getCompanyId()));
    } catch (Exception e) {
        _log.error(e, e);
    }

    setTemplateNamespace("Flags.render");

    return super.doStartTag();
}

From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java

License:Open Source License

private JSONObject _getDataJSONObject(Map<String, Object> context) {
    String namespace = PortalUtil.getPortletNamespace(PortletKeys.FLAGS);

    JSONObject dataJSONObject = JSONFactoryUtil.createJSONObject();

    dataJSONObject.put(namespace + "className", context.get("className"));
    dataJSONObject.put(namespace + "classPK", context.get("classPK"));
    dataJSONObject.put(namespace + "contentTitle", context.get("contentTitle"));
    dataJSONObject.put(namespace + "contentURL", _getCurrentURL());
    dataJSONObject.put(namespace + "reportedUserId", context.get("reportedUserId"));

    return dataJSONObject;
}

From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java

License:Open Source License

private String _getURI() throws WindowStateException {
    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FLAGS,
            PortletRequest.ACTION_PHASE);

    portletURL.setParameter(ActionRequest.ACTION_NAME, "/flags/edit_entry");

    return portletURL.toString();
}