Deleting the user and Changing the status : Active and Deactive of the user



Here is the following code to delete the user and change the status of the user

In Liferay After deactivating the user then only we can delete the user.

It is the below code what liferay is using to delete and update the status of the user.


 protected void deleteUsers(ActionRequest actionRequest) throws Exception {

             String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

             //Getting the List of all the Users
             long[] deleteUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteUserIds"), 0L);

             // Based on the user status selected we are changing the status
             for (long deleteUserId : deleteUserIds) {
                       if (cmd.equals(Constants.DEACTIVATE) ||  cmd.equals(Constants.RESTORE)) {

                                int status = WorkflowConstants.STATUS_APPROVED;

                                if (cmd.equals(Constants.DEACTIVATE)) {
                                        status = WorkflowConstants.STATUS_INACTIVE;
                                  }

                         UserLocalServiceUtil.updateStatus(deleteUserId, status); // Updating the Status
                   }

               else  {

                UserLocalServiceUtil.deleteUser(deleteUserId); // Deleting the Status.

                }
           }
}

Comments

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate