public virtual void SaveAppRole() {

            String appRoles = ctx.Post( "appRole" );
            AppRole.DeleteAll();

            if (strUtil.HasText( appRoles )) {

                string[] values = appRoles.Split( ',' );
                foreach (String str in values) {

                    if (strUtil.IsNullOrEmpty( str )) continue;
                    string[] arrItem = str.Split( '_' );
                    if (arrItem.Length != 3) continue;

                    int appId = cvt.ToInt( arrItem[0] );
                    int roleId = cvt.ToInt( arrItem[1] );
                    if (appId <= 0 || roleId < 0) continue;

                    String roleType = arrItem[2];

                    AppRole ar = new AppRole();
                    ar.AppId = appId;
                    ar.RoleId = roleId;
                    ar.RoleType = roleType;

                    ar.insert();
                }
            }
            log( SiteLogString.UpdateFrontPermission() );

            echoRedirect( lang( "saved" ) );

        }
Ejemplo n.º 2
0
        public static void DeleteAll()
        {
            IList allAppRoles = new AppRole().findAll();

            foreach (AppRole ar in allAppRoles) {
                ar.delete();
            }
        }
Ejemplo n.º 3
0
        //---------------------------------------------------------------------------------
        public static bool IsRoleInApp(long roleId, string roleType, long appId)
        {
            IList configAll = new AppRole().findAll();
            foreach (AppRole ac in configAll) {

                if (ac.AppId == appId && ac.RoleId == roleId &&
                    (ac.RoleType != null && ac.RoleType.Equals(roleType))
                    )
                    return true;
            }
            return false;
        }
Ejemplo n.º 4
0
        //---------------------------------------------------------------------------------

        public static Boolean IsRoleInApp(int roleId, String roleType, int appId)
        {
            IList configAll = new AppRole().findAll();

            foreach (AppRole ac in configAll)
            {
                if (ac.AppId == appId && ac.RoleId == roleId &&
                    (ac.RoleType != null && ac.RoleType.Equals(roleType))
                    )
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        //---------------------------------------------------------------------------------
        public static void InitSiteFront( long appId )
        {
            AppRole guest = new AppRole();
            guest.AppId = appId;
            guest.RoleId = SiteRole.Guest.Id;
            guest.RoleType = typeof( SiteRole ).FullName;
            guest.insert();

            AppRole normal = new AppRole();
            normal.AppId = appId;
            normal.RoleId = SiteRole.NormalMember.Id;
            normal.RoleType = typeof( SiteRole ).FullName;
            normal.insert();

            AppRole admin = new AppRole();
            admin.AppId = appId;
            admin.RoleId = SiteRole.Administrator.Id;
            admin.RoleType = typeof( SiteRole ).FullName;
            admin.insert();
        }
Ejemplo n.º 6
0
        //---------------------------------------------------------------------------------

        public static void InitSiteFront(int appId)
        {
            AppRole guest = new AppRole();

            guest.AppId    = appId;
            guest.RoleId   = SiteRole.Guest.Id;
            guest.RoleType = typeof(SiteRole).FullName;
            guest.insert();

            AppRole normal = new AppRole();

            normal.AppId    = appId;
            normal.RoleId   = SiteRole.NormalMember.Id;
            normal.RoleType = typeof(SiteRole).FullName;
            normal.insert();

            AppRole admin = new AppRole();

            admin.AppId    = appId;
            admin.RoleId   = SiteRole.Administrator.Id;
            admin.RoleType = typeof(SiteRole).FullName;
            admin.insert();
        }