掲示板

Kaleo Single Approver Workflow: direct publish

11年前 に Luca Lupo によって更新されました。

Kaleo Single Approver Workflow: direct publish

Regular Member 投稿: 106 参加年月日: 12/10/01 最新の投稿
Is it possible to say to Kaleo to Publish directly if the web content is created by a specific role?

I mean, the Admin right now can create content (that will be in status pending) and then he can approve the content. What I want is to have two roles:

1. Publisher (users who can create contents but not to approve them). So when a user creates a content it will be in pending status;
2. Approver (users who can approve the contents). They approve the contents, but in the case they create contents, such contents are automatically published as approved.

Any hint?
thumbnail
11年前 に Christoph Rabel によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

Liferay Legend 投稿: 1554 参加年月日: 09/09/24 最新の投稿
Yes.
Change Single Approver Workflow and add a condition:


        <state>
                <name>created</name>
                <initial>true</initial>
                <transitions>
                        <transition>
                                <name>Determine Review</name>
                                <target>review-or-approve</target>
                                <default>true</default>
                        </transition>
                </transitions>
        </state>

        <condition>
                <name>review-or-approve</name>
                <script> <![CDATA[
                                import com.liferay.portal.service.RoleLocalServiceUtil;
                                import com.liferay.portal.kernel.util.GetterUtil;
                                import com.liferay.portal.kernel.workflow.WorkflowConstants;

                                try {
                                        returnValue = "Review";
                                        long userid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
                                        long companyid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
                                        String[] roles={"Approver","Administrator"};
                                        if (RoleLocalServiceUtil.hasUserRoles(userid, companyid, roles, true)) returnValue = "Approved";
                                } catch (Exception e) {
                                  e.printStackTrace();
                                }
                        ]]> </script>
                <script-language>beanshell</script-language>
                <transitions>
                        <transition>
                                <name>Review</name>
                                <target>review</target>
                                <default>false</default>
                        </transition>
                        <transition>
                                <name>Approved</name>
                                <target>approved</target>
                                <default>false</default>
                        </transition>
                </transitions>
        </condition>
11年前 に Luca Lupo によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

Regular Member 投稿: 106 参加年月日: 12/10/01 最新の投稿
Is it enough to change the xml inside the kaleo-web present in webapp folder of tomcat?

If so, I have this...but it seems that nothing happens emoticon



<!--?xml version="1.0"?-->


<workflow-definition xmlns="urn:liferay.com:liferay-workflow_6.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="urn:liferay.com:liferay-workflow_6.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_1_0.xsd">
	<name>Single Approver</name>
	<description>A single approver can approve a workflow content.</description>
	<version>1</version>

	 <state>
            <name>created</name>
            <initial>true</initial>
            <transitions>
                <transition>
            		<name>Determine Review</name>
                	<target>review-or-approve</target>
                	<default>true</default>
            	</transition>
            </transitions>
    </state>
    <condition>
		<name>review-or-approve</name>
		<script> <![CDATA[
						import com.liferay.portal.service.RoleLocalServiceUtil;
						import com.liferay.portal.kernel.util.GetterUtil;
						import com.liferay.portal.kernel.workflow.WorkflowConstants;

						try {
								returnValue = "Review";
								long userid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
								long companyid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
								String[] roles={"Approver","Administrator"};
								if (RoleLocalServiceUtil.hasUserRoles(userid, companyid, roles, true)) returnValue = "Approved";
						} catch (Exception e) {
						  e.printStackTrace();
						}
				]]> </script>
		<script-language>beanshell</script-language>
		<transitions>
				<transition>
						<name>Review</name>
						<target>review</target>
						<default>false</default>
				</transition>
				<transition>
						<name>Approved</name>
						<target>approved</target>
						<default>false</default>
				</transition>
		</transitions>
    </condition>
	<task>
		<name>update</name>
		<metadata>
			{"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[328,199]}
		</metadata>
		<actions>
			<action>
				<name>reject</name>
				<script>
					<![CDATA[
						Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("denied"), workflowContext);
						Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("pending"), workflowContext);
					]]>
				</script>
				<script-language>javascript</script-language>
				<execution-type>onAssignment</execution-type>
			</action>
			<notification>
				<name>Creator Modification Notification</name>
				<template>Your submission was rejected by a reviewer, please modify and resubmit.</template>
				<template-language>text</template-language>
				<notification-type>email</notification-type>
				<execution-type>onAssignment</execution-type>
			</notification>
		</actions>
		<assignments>
			<user />
		</assignments>
		<transitions>
			<transition>
				<name>resubmit</name>
				<target>review</target>
			</transition>
		</transitions>
	</task>
	<task>
		<name>review</name>
		<metadata>
			{"xy":[168,36]}
		</metadata>
		<actions>
			<notification>
				<name>Review Notification</name>
				<template>You have a new submission waiting for your review in the workflow.</template>
				<template-language>text</template-language>
				<notification-type>email</notification-type>
				<execution-type>onAssignment</execution-type>
			</notification>
			<notification>
				<name>Review Completion Notification</name>
				<template>
					Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template>
				<template-language>freemarker</template-language>
				<notification-type>email</notification-type>
				<recipients>
					<user />
				</recipients>
				<execution-type>onExit</execution-type>
			</notification>
		</actions>
		<assignments>
			<roles>
				<role>
					<role-type>organization</role-type>
					<name>Organization Administrator</name>
				</role>
				<role>
					<role-type>organization</role-type>
					<name>Organization Content Reviewer</name>
				</role>
				<role>
					<role-type>organization</role-type>
					<name>Organization Owner</name>
				</role>
				<role>
					<role-type>regular</role-type>
					<name>Administrator</name>
				</role>
				<role>
					<role-type>regular</role-type>
					<name>Portal Content Reviewer</name>
				</role>
				<role>
					<role-type>site</role-type>
					<name>Site Administrator</name>
				</role>
				<role>
					<role-type>site</role-type>
					<name>Site Content Reviewer</name>
				</role>
				<role>
					<role-type>site</role-type>
					<name>Site Owner</name>
				</role>
			</roles>
		</assignments>
		<transitions>
			<transition>
				<name>approve</name>
				<target>approved</target>
			</transition>
			<transition>
				<name>reject</name>
				<target>update</target>
				<default>false</default>
			</transition>
		</transitions>
	</task>
	<state>
		<name>approved</name>
		<metadata>
			
				{"xy":[380,51]}
			
		</metadata>
		<actions>
			<action>
				<name>approve</name>
				<script>
					<![CDATA[
						Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);
					]]>
				</script>
				<script-language>javascript</script-language>
				<execution-type>onEntry</execution-type>
			</action>
		</actions>
	</state>
</workflow-definition>
11年前 に Luca Lupo によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

Regular Member 投稿: 106 参加年月日: 12/10/01 最新の投稿
Thanks, that worked emoticon

Now I'm trying to understand the sending email. I know that Kaleo sends emails when a new content is created, when the content is assigned to someone, and when it is rejected or approved. And I suppose that when the content is assigned to someone, the email arrives to this "someone", but in the other two cases I dunno who will be the receiver.
thumbnail
11年前 に Harish Kumar によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
Content creator will get the mail in case of approval/rejection.
thumbnail
11年前 に Jacques Traore によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

Junior Member 投稿: 49 参加年月日: 13/01/21 最新の投稿
Luca Lupo:
Thanks, that worked emoticon

Now I'm trying to understand the sending email. I know that Kaleo sends emails when a new content is created, when the content is assigned to someone, and when it is rejected or approved. And I suppose that when the content is assigned to someone, the email arrives to this "someone", but in the other two cases I dunno who will be the receiver.



Hi Lucas,
Was it (finally) enough for you changing directly ..\tomcat-7.0.27\webapps\kaleo-web\WEB-INF\classes\META-INF\definitions\single-approver-definition.xml ?
Because I did the same and it doesn't seem to work.

Thanks by advance.
11年前 に Vika Tory によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

New Member 投稿: 1 参加年月日: 12/10/30 最新の投稿
Hi,

I need to have role (Administrator) which can create contents and these contents are automatically published as approved.
I've tried to use xml that Christoph gave but it still does't work for me. Does anybody know what can be the problem?

Thanks emoticon
thumbnail
11年前 に Lukas Kornprobst によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

New Member 投稿: 1 参加年月日: 12/04/12 最新の投稿
Hi,

What is the type of your role? (Site Role, Regular Role, etc.)

Christpoh Condition script is an verry good approach (thx for that emoticon ), but it worked for me only with "Regular Roles", not with "Site Roles" (Liferay v6.1).
So i changed the script in the condition tag with the following:


            <script><![CDATA[import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;


try {
	returnValue = "review";
	long userId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
	long groupId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_GROUP_ID));
	String role = "Approver";
	
	if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(userId, groupId, role, true)) returnValue = "approved";
} catch (Exception e) {
	e.printStackTrace(); 
}
]]></script>

After the change, everything went without any problems with Site Roles for me.
The variable "role" must be changed with your "Site Role" (Administrator).
thumbnail
8年前 に Ashish Agarwal によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

New Member 投稿: 13 参加年月日: 15/07/07 最新の投稿
Hi Christoph,

I have tried your xml changes. The workflow is getting approved perfectly due to the code but the asset which is added has the status "Pending Approval" even if the workflow is approved.

Could you let me know what maybe the problem here?
thumbnail
8年前 に Ashish Agarwal によって更新されました。

RE: Kaleo Single Approver Workflow: direct publish

New Member 投稿: 13 参加年月日: 15/07/07 最新の投稿
Found the root cause of my issue.

It was a synchronization issue between the portal and DB.