Example #1
0
        public virtual IList <DynamicMenu> GetRootMenus(Context context)
        {
            if (context.User.IsDisable)
            {
                return(null);
            }

            IList <DynamicMenu> rootMenus;

            rootMenus = DynamicMenu.GetTopMenus(context, this.SystemID);

            //mark accessible menus
            foreach (UserRole ur in context.User.UserRoles)
            {
                if (ur.Role.SystemID == this.SystemID && ur.EffectivePeriod.IsEffective())
                {
                    foreach (RoleMenu rm in ur.Role.Menus)
                    {
                        if (rm.Menu.IsObsolete)
                        {
                            continue;
                        }
                        bool found = rootMenus.MarkMenuAsAccessible(rm.Menu);
                        if (!found)
                        {
                            throw new iSabayaException(String.Format("The role menu (id={0}) does not belong to the system (SystemID={1}).",
                                                                     rm.Menu.Id, this.SystemID));
                        }
                    }
                }
            }

            return(rootMenus);
        }
Example #2
0
 public static RoleMenu Find(Context context, Role role, DynamicMenu menu)
 {
     return(context.PersistenceSession
            .CreateCriteria <RoleMenu>()
            .Add(Expression.Eq("Role", role))
            .Add(Expression.Eq("Menu", menu))
            .UniqueResult <RoleMenu>());
 }
Example #3
0
        public override bool Equals(object obj)
        {
            DynamicMenu menu = obj as DynamicMenu;

            if (null == menu)
            {
                return(false);
            }
            return(this.Id == menu.Id);
        }
Example #4
0
        public static bool MarkMenuAsAccessible(this IList <DynamicMenu> roots, DynamicMenu menu)
        {
            bool found = false;

            foreach (DynamicMenu m in roots)
            {
                if (m.Id == menu.Id)
                {
                    m.Show = true;
                    found  = true;
                    break;
                }
                else if (m.Children.MarkMenuAsAccessible(menu))
                {
                    found = true;
                    break;
                }
            }

            return(found);
        }
Example #5
0
        public static DynamicMenu Find(Context context, int id)
        {
            DynamicMenu dynamicMenu = (DynamicMenu)context.PersistenceSession.Get(typeof(DynamicMenu), id);

            return(dynamicMenu);
        }