package info.bukova.isspst.ui;

import info.bukova.isspst.security.AuthMethod;
import info.bukova.isspst.services.users.UserService;

import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window;

public class MainMenu
{
	private String contextPath;

	private String moduleUrl;
	@WireVariable
	private UserService userService;

	@Init
	public void init()
	{
		this.contextPath = Executions.getCurrent().getContextPath();
		this.moduleUrl = Executions.getCurrent().getDesktop().getRequestPath();
	}

	public String getContextPath()
	{
		return this.contextPath;
	}

	public String getModuleUrl()
	{
		return this.moduleUrl;
	}

	@Command
	public void passwd()
	{
		Window window = (Window) Executions.createComponents("/app/passwd.zul", null, null);
		window.doModal();
	}

	@Command
	public void numSeries()
	{
		Window window = (Window) Executions.createComponents("/settings/seasons.zul", null, null);
		window.doModal();
	}

	@Command
	public void globalSettings()
	{
		Window window = (Window) Executions.createComponents("/settings/globalSettings.zul", null, null);
		window.doModal();
	}
	
	@Command
	public void userSettings()
	{
		Window window = (Window) Executions.createComponents("/settings/userSettings.zul", null, null);
		window.doModal();
	}
	
	public boolean isCanChangePassword() {
		return userService.getAuthMethod() == AuthMethod.DATABASE;
	}
}
