/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package admin;

import entities.Users;
import helper.MenuItem;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author Szilárd
 */
@ManagedBean(name="Menu")
@RequestScoped
public class Menu {

    /*
                    <li><a href="faces/listsemester.jsp">Félév</a></li>
                    <li><a href="faces/listsubject.jsp">Tárgyak hírdetése</a></li>
                    <li><a href="faces/listcurrentsubject.jsp">Meghírdetett tárgyak</a></li>
                    <li><a href="faces/listthesis.jsp">Diplomamunka</a></li>
     */
    /** Creates a new instance of Menu */
    Users user;
    List<MenuItem> menu;
    boolean admin = false, student = false, teacher = false;
    public Menu() {
        Map map = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
        user = (Users) map.get("felhasznalo");
        menu = new LinkedList<MenuItem>();
        switch(user.getUserRole()){
            case ADMIN:
                admin = true;
                for(MenuItem akt : MenuItem.listMenu){
                    if(akt.isAdmin())
                        menu.add(akt);
                }
                break;
            case TEACHER:
                teacher = true;
                for(MenuItem akt : MenuItem.listMenu){
                    if(akt.isTeacher())
                        menu.add(akt);
                }
                break;
            case STUDENT:
                student = true;
                for(MenuItem akt : MenuItem.listMenu){
                    if(akt.isStudent())
                        menu.add(akt);
                }
                break;
        }
    }

    public List<MenuItem> getMenu() {
        return menu;
    }

    public void setMenu(List<MenuItem> menu) {
        this.menu = menu;
    }

    
    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public boolean isAdmin() {
        return admin;
    }

    public void setAdmin(boolean admin) {
        this.admin = admin;
    }

    public boolean isStudent() {
        return student;
    }

    public void setStudent(boolean student) {
        this.student = student;
    }

    public boolean isTeacher() {
        return teacher;
    }

    public void setTeacher(boolean teacher) {
        this.teacher = teacher;
    }



}
