Exemplo n.º 1
0
        public void SavePrivacy()
        {
            Boolean isUserPrivacyClose = Component.IsClose(typeof(UserPrivacy));

            if (isUserPrivacyClose)
            {
                echo("对不起,本功能已经停用");
                return;
            }

            //---------------------------------------------------------


            User user = ctx.owner.obj as User;

            if (user == null)
            {
                echoRedirect(lang("exUser"));
                return;
            }

            Dictionary <string, int> settings = UserSecurity.GetSettingsAll(user);
            Dictionary <string, int> values   = new Dictionary <string, int>();

            foreach (KeyValuePair <string, int> s in settings)
            {
                int val = UserPrivacy.GetDefaultValue();
                if (ctx.PostHas(s.Key))
                {
                    val = ctx.PostInt(s.Key);
                }

                values.Add(s.Key, val);
            }

            String settingsStr = UserSecurity.Save(values);


            user.Security = settingsStr;
            db.update(user, "Security");

            echoRedirect(lang("opok"));
        }
Exemplo n.º 2
0
        //----------------------------------------------------------------------------------------------------------

        public void Privacy()
        {
            Boolean isUserPrivacyClose = Component.IsClose(typeof(UserPrivacy));

            if (isUserPrivacyClose)
            {
                echo("对不起,本功能已经停用");
                return;
            }

            //---------------------------------------------------------

            User user = ctx.owner.obj as User;

            if (user == null)
            {
                echoRedirect(lang("exUser"));
                return;
            }

            target(SavePrivacy);

            String lbl = string.Format(lang("appPrivacyInfo"), to(new AppController().Index));

            set("appPrivacyInfo", lbl);

            set("profileEditLink", to(Profile));
            set("appListLink", to(new AppController().Index));

            Dictionary <string, int> settings = UserSecurity.GetSettingsAll(user);

            foreach (KeyValuePair <string, int> s in settings)
            {
                set(s.Key, Html.DropList(UserPrivacy.DropOptions, s.Key, "Name", "Value", s.Value));
            }

            // app permission
            IList apps = userAppService.GetByMember(ctx.owner.Id);

            bindAppList(apps);
        }