Esempio n. 1
0
 protected void CheckUserPower(string powerString, PowerCheckType powerCheckType)
 {
     if (!CompareUserPower(powerString, powerCheckType))
     {
         ScriptHelper.Alert(ShopLanguage.ReadLanguage("NoPower"));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 比较权限类的字符串
        /// </summary>
        /// <param name="powerString">比较字符串,用','隔开</param>
        /// <param name="powerCheckType">比较类型</param>
        /// <returns></returns>
        public bool CompareUserPower(string powerString, PowerCheckType powerCheckType)
        {
            string power    = AdminGroupBLL.ReadAdminGroupCache(this.UserGroupID).Power;
            bool   flag     = false;
            string powerKey = ShopConfig.ReadConfigInfo().PowerKey;

            switch (powerCheckType)
            {
            case PowerCheckType.Single:
                if (power.IndexOf("|" + powerKey + powerString + "|") > -1)
                {
                    flag = true;
                }
                break;

            case PowerCheckType.OR:
                foreach (string str2 in powerString.Split(new char[] { ',' }))
                {
                    if (power.IndexOf("|" + powerKey + str2 + "|") > -1)
                    {
                        flag = true;
                        break;
                    }
                }
                break;

            case PowerCheckType.AND:
                flag = true;
                foreach (string str2 in powerString.Split(new char[] { ',' }))
                {
                    if (power.IndexOf("|" + powerKey + str2 + "|") == -1)
                    {
                        flag = false;
                        break;
                    }
                }
                break;
            }
            return(flag);
        }
Esempio n. 3
0
 ///<summary>
 ///检查用户权限
 ///</summary>
 ///<param name="powerKey">权限的前缀</param>
 ///<param name="powerString">要检查的权限值</param>
 ///<param name="checktype">检查类型</param>
 ///<returns></returns>
 protected void CheckAdminPower(string powerString, PowerCheckType powerCheckType)
 {
     CheckAdminPower(ShopConfig.ReadConfigInfo().PowerKey, powerString, PowerCheckType.Single, ref AdminID);
 }
Esempio n. 4
0
        ///<summary>
        ///检查用户权限
        ///</summary>
        ///<param name="powerKey">权限的前缀</param>
        ///<param name="powerString">要检查的权限值</param>
        ///<param name="checktype">检查类型</param>
        ///<returns></returns>
        private void CheckAdminPower(string powerKey, string powerString, PowerCheckType powerCheckType, ref int adminID)
        {
            string power = AdminGroupBLL.Read(Cookies.Admin.GetGroupID(false)).Power;
            //检查权限
            bool checkPower = false;

            switch (powerCheckType)
            {
            case PowerCheckType.Single:
                if (power.IndexOf("|" + powerKey + powerString + "|") > -1)
                {
                    checkPower = true;
                }
                break;

            case PowerCheckType.OR:
                foreach (string TempPowerString in powerString.Split(','))
                {
                    if (power.IndexOf("|" + powerKey + TempPowerString + "|") > -1)
                    {
                        checkPower = true;
                        break;
                    }
                }
                break;

            case PowerCheckType.AND:
                checkPower = true;
                foreach (string TempPowerString in powerString.Split(','))
                {
                    if (power.IndexOf("|" + powerKey + TempPowerString + "|") == -1)
                    {
                        checkPower = false;
                        break;
                    }
                }
                break;

            default:
                break;
            }
            if (checkPower)
            {
                //是否需要检查具有操作别人的权限
                bool      needOther = false;
                Hashtable ht        = ReadAllNeedOther();
                foreach (DictionaryEntry dic in ht)
                {
                    if (dic.Key.ToString() == powerString)
                    {
                        needOther = Convert.ToBoolean(dic.Value);
                        if (!needOther)
                        {
                            break;
                        }
                    }
                }

                // 检查是否具有操作别人的权限
                if (needOther)
                {
                    if (power.IndexOf("|" + powerKey + "ManageOther|") > -1)
                    {
                        adminID = int.MinValue;
                    }
                    else
                    {
                        adminID = Cookies.Admin.GetAdminID(false);
                    }
                }
                else
                {
                    adminID = int.MinValue;
                }
            }
            else
            {
                adminID = -1;
            }
            if (adminID == -1)
            {
                ScriptHelper.AlertFront(ShopLanguage.ReadLanguage("NoPower"));
            }
        }
Esempio n. 5
0
        private void CheckAdminPower(string powerKey, string powerString, PowerCheckType powerCheckType, ref int adminID)
        {
            string power = AdminGroupBLL.ReadAdminGroupCache(Cookies.Admin.GetGroupID(false)).Power;
            bool   flag  = false;

            switch (powerCheckType)
            {
            case PowerCheckType.Single:
                if (power.IndexOf("|" + powerKey + powerString + "|") > -1)
                {
                    flag = true;
                }
                break;

            case PowerCheckType.OR:
                foreach (string str2 in powerString.Split(new char[] { ',' }))
                {
                    if (power.IndexOf("|" + powerKey + str2 + "|") > -1)
                    {
                        flag = true;
                        break;
                    }
                }
                break;

            case PowerCheckType.AND:
                flag = true;
                foreach (string str2 in powerString.Split(new char[] { ',' }))
                {
                    if (power.IndexOf("|" + powerKey + str2 + "|") == -1)
                    {
                        flag = false;
                        break;
                    }
                }
                break;
            }
            if (!flag)
            {
                adminID = -1;
            }
            else
            {
                bool      flag2     = false;
                Hashtable hashtable = this.ReadAllNeedOther();
                foreach (DictionaryEntry entry in hashtable)
                {
                    if (entry.Key.ToString() == powerString)
                    {
                        flag2 = Convert.ToBoolean(entry.Value);
                        if (!flag2)
                        {
                            break;
                        }
                    }
                }
                if (flag2)
                {
                    if (power.IndexOf("|" + powerKey + "ManageOther|") > -1)
                    {
                        adminID = -2147483648;
                    }
                    else
                    {
                        adminID = Cookies.Admin.GetAdminID(false);
                    }
                }
                else
                {
                    adminID = -2147483648;
                }
            }
            if (adminID == -1)
            {
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("NoPower"));
            }
        }