// Path: src/java/is/idega/idegaweb/egov/message/data/MessageReceiver.java
// public interface MessageReceiver extends IDOEntity, User {
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#receiveEmails
// 	 */
// 	public boolean receiveEmails();
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#setReceiveEmails
// 	 */
// 	public void setReceiveEmails(boolean receiveEmails);
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#receiveMessagesToBox
// 	 */
// 	public boolean receiveMessagesToBox();
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#setReceiveMessagesToBox
// 	 */
// 	public void setReceiveMessagesToBox(boolean receiveMessages);
// }
// 
// Path: src/java/is/idega/idegaweb/egov/message/data/MessageReceiverHome.java
// public interface MessageReceiverHome extends IDOHome {
// 
// 	public MessageReceiver create() throws CreateException;
// 
// 	public MessageReceiver findByPrimaryKey(Object pk) throws FinderException;
// }


import is.idega.idegaweb.egov.message.data.MessageReceiver;
import is.idega.idegaweb.egov.message.data.MessageReceiverHome;
import java.util.Collection;
import javax.ejb.FinderException;
import com.idega.business.IBOSessionBean;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWPropertyList;
import com.idega.user.business.UserProperties;
import com.idega.user.data.User;
		}
		return true;
	}

	public void setIfUserPreferesMessageByEmail(boolean preference) {
		MessageReceiver receiver = getMessageReceiver();
		if (receiver != null) {
			receiver.setReceiveEmails(preference);
			receiver.store();
		}
		else {
			IWPropertyList propertyList = getUserMessagePreferences();
			propertyList.setProperty(USER_PROP_SEND_TO_EMAIL, new Boolean(preference));
		}
	}

	public void setIfUserPreferesMessageInMessageBox(boolean preference) {
		MessageReceiver receiver = getMessageReceiver();
		if (receiver != null) {
			receiver.setReceiveMessagesToBox(preference);
			receiver.store();
		}
		else {
			IWPropertyList propertyList = getUserMessagePreferences();
			propertyList.setProperty(USER_PROP_SEND_TO_MESSAGE_BOX, new Boolean(preference));
		}
	}

	private MessageReceiver getMessageReceiver() {
		try {
// Path: src/java/is/idega/idegaweb/egov/message/data/MessageReceiver.java
// public interface MessageReceiver extends IDOEntity, User {
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#receiveEmails
// 	 */
// 	public boolean receiveEmails();
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#setReceiveEmails
// 	 */
// 	public void setReceiveEmails(boolean receiveEmails);
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#receiveMessagesToBox
// 	 */
// 	public boolean receiveMessagesToBox();
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.message.data.MessageReceiverBMPBean#setReceiveMessagesToBox
// 	 */
// 	public void setReceiveMessagesToBox(boolean receiveMessages);
// }
// 
// Path: src/java/is/idega/idegaweb/egov/message/data/MessageReceiverHome.java
// public interface MessageReceiverHome extends IDOHome {
// 
// 	public MessageReceiver create() throws CreateException;
// 
// 	public MessageReceiver findByPrimaryKey(Object pk) throws FinderException;
// }


// Path: src/java/is/idega/idegaweb/egov/message/business/MessageSessionBean.java
import is.idega.idegaweb.egov.message.data.MessageReceiver;
import is.idega.idegaweb.egov.message.data.MessageReceiverHome;
import java.util.Collection;
import javax.ejb.FinderException;
import com.idega.business.IBOSessionBean;
import com.idega.data.IDOLookup;
import com.idega.data.IDOLookupException;
import com.idega.idegaweb.IWPropertyList;
import com.idega.user.business.UserProperties;
import com.idega.user.data.User;

		}
		return true;
	}

	public void setIfUserPreferesMessageByEmail(boolean preference) {
		MessageReceiver receiver = getMessageReceiver();
		if (receiver != null) {
			receiver.setReceiveEmails(preference);
			receiver.store();
		}
		else {
			IWPropertyList propertyList = getUserMessagePreferences();
			propertyList.setProperty(USER_PROP_SEND_TO_EMAIL, new Boolean(preference));
		}
	}

	public void setIfUserPreferesMessageInMessageBox(boolean preference) {
		MessageReceiver receiver = getMessageReceiver();
		if (receiver != null) {
			receiver.setReceiveMessagesToBox(preference);
			receiver.store();
		}
		else {
			IWPropertyList propertyList = getUserMessagePreferences();
			propertyList.setProperty(USER_PROP_SEND_TO_MESSAGE_BOX, new Boolean(preference));
		}
	}

	private MessageReceiver getMessageReceiver() {
		try {
			MessageReceiverHome home = (MessageReceiverHome) IDOLookup.getHome(MessageReceiver.class);