public bool AddUserToRole(DotNetNuke.Entities.Users.UserInfo user, string roleName)
        {
            bool rc = false;

            DotNetNuke.Security.Roles.RoleController roleCtl = new DotNetNuke.Security.Roles.RoleController();
            DotNetNuke.Security.Roles.RoleInfo       newRole = roleCtl.GetRoleByName(user.PortalID, roleName);

            if (newRole == null)
            {
                throw new Exception("No existe el Rol [" + roleName + "] en el sistema");
            }
            else if (user == null)
            {
                throw new Exception("La información de usuario se encuentra vacía");
            }
            else
            {
                rc = user.IsInRole(roleName);
                if (!rc)
                {
                    roleCtl.AddUserRole(user.PortalID, user.UserID, newRole.RoleID, DateTime.MinValue, DateTime.MaxValue);
                    user = DotNetNuke.Entities.Users.UserController.GetUserById(user.PortalID, user.UserID);
                    rc   = user.IsInRole(roleName);
                }
            }

            return(rc);
        }
Exemplo n.º 2
0
        public string getUserID()
        {
            DotNetNuke.Entities.Users.UserInfo currentuser = UserInfo;
            string userid = currentuser.Username.ToString();

            return(userid);
        }
Exemplo n.º 3
0
        public InviteRecipientUser(DotNetNuke.Entities.Users.UserInfo dnnUser, int inviteUserId)
        {
            if (dnnUser != null)
            {
                UserId      = dnnUser.UserID;
                FirstName   = dnnUser.FirstName;
                LastName    = dnnUser.LastName;
                DisplayName = dnnUser.DisplayName;
                JoinedDate  = dnnUser.CreatedOnDate;
                IsVisible   = !dnnUser.IsDeleted;
                Status      = "Not Connected";
                var rel = dnnUser.Social.UserRelationships.Where(x => x.UserId == inviteUserId).FirstOrDefault();
                if (rel != null)
                {
                    switch (rel.Status)
                    {
                    case DotNetNuke.Entities.Users.Social.RelationshipStatus.Accepted:
                        Status = "Friends";
                        break;

                    case DotNetNuke.Entities.Users.Social.RelationshipStatus.Pending:
                        Status = "Pending Friend Request";
                        break;
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region ViewPermission
            // Truyen vao tabid va mid de he thong kiem tra
            // Neu User dang truy cap co quyen thi he thong tra ra du lieu
            // Neu user khong co quyen he thong se thong bao not define
            try
            {
                DotNetNuke.Entities.Portals.PortalSettings portalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();
                if (((Request.QueryString["tabid"] == null && Request.Form["tabid"] == null) || (Request.QueryString["mid"] == null && Request.Form["mid"] == null)) || !(Request.IsAuthenticated))
                {
                    WriteDataError("NotAuthenticated");
                    return;
                }
                // get TabId
                int TabId = -1;
                if ((Request.QueryString["tabid"] != null))
                {
                    TabId = Int32.Parse(Request.QueryString["tabid"]);
                }
                else if ((Request.Form["tabid"] != null))
                {
                    TabId = Int32.Parse(Request.Form["tabid"]);
                }

                // get ModuleId
                int ModuleId = -1;
                if ((Request.QueryString["mid"] != null))
                {
                    ModuleId = Int32.Parse(Request.QueryString["mid"]);
                }
                else if ((Request.Form["mid"] != null))
                {
                    ModuleId = Int32.Parse(Request.Form["mid"]);
                }
                objUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                DotNetNuke.Entities.Modules.ModuleController mc = new DotNetNuke.Entities.Modules.ModuleController();
                System.Collections.Hashtable settings           = mc.GetModuleSettings(ModuleId);
                objModuleInfo = new DotNetNuke.Entities.Modules.ModuleController().GetModule(ModuleId, TabId);

                if (DotNetNuke.Security.Permissions.ModulePermissionController.CanViewModule(objModuleInfo))
                {
                    try
                    {
                        WriteData();
                    }
                    catch (Exception ex)
                    {
                        WriteDataError(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                WriteDataError(ex.Message);
            }
            #endregion
            base.OnInit(e);
        }
 public override void Init(string[] args, DotNetNuke.Entities.Portals.PortalSettings portalSettings,
                           DotNetNuke.Entities.Users.UserInfo userInfo, int activeTabId)
 {
     base.Init(args, portalSettings, userInfo, activeTabId);
     LogType = GetFlagValue(FlagLogType, "LogType", "");
     Enabled = GetFlagValue <bool?>(FlagEnabled, "Enabled", null);
     Notify  = GetFlagValue <bool?>(FlagNotify, "Notify", null);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            string strData = "-1";

            try
            {
                objUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

                if (((Request.QueryString["userid"] != null) && (Request.QueryString["status"] != null) && (Request.QueryString["id"] != null) && (Request.QueryString["action"] != null)) ||
                    ((Request.Form["userid"] != null) && (Request.Form["status"] != null) && (Request.Form["id"] != null) && (Request.Form["action"] != null)))
                {
                    int    userid = -1;
                    int    status = -1;
                    int    id     = -1;
                    string action = "capnhat";
                    if (Request.QueryString["id"] != null)
                    {
                        userid = int.Parse(Request.QueryString["userid"]);
                        status = int.Parse(Request.QueryString["status"]);
                        id     = int.Parse(Request.QueryString["id"]);
                        action = Request.QueryString["action"];
                    }
                    else
                    {
                        userid = int.Parse(Request.Form["userid"]);
                        status = int.Parse(Request.Form["status"]);
                        id     = int.Parse(Request.Form["id"]);
                        action = Request.Form["action"];
                    }
                    if (userid.Equals(objUserInfo.UserID))
                    {
                        strData = "-1";
                        if (action.Equals("capnhat"))
                        {
                            data.dnn_NuceQLHPM_CaHoc_Items.updateStatus(id, status);
                            strData = "1";
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        strData = "-2";
                    }
                }
            }
            catch (Exception ex)
            {
                strData = ex.Message;
            }
            Response.Clear();
            Response.ContentType = "text/plain";
            Response.Write(strData);
        }
 public override bool IsAuthorized(AuthFilterContext context)
 {
     if (context != null)
     {
         DotNetNuke.Entities.Users.UserInfo UserInfo = ((DnnApiController)context.ActionContext.ControllerContext.Controller).UserInfo;
         if (UserInfo != null)
         {
             return(UserInfo.IsInRole("Administrators"));
         }
     }
     return(false);
 }
        public bool CreateDnnUser(DotNetNuke.Entities.Users.UserInfo user, string roleName = "")
        {
            DotNetNuke.Security.Membership.UserCreateStatus   objUserCreateStatus   = DotNetNuke.Security.Membership.UserCreateStatus.AddUser;
            DotNetNuke.Security.Membership.MembershipProvider objMembershipProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance();

            objUserCreateStatus = objMembershipProvider.CreateUser(ref user);

            bool status = false;

            switch (objUserCreateStatus)
            {
            case DotNetNuke.Security.Membership.UserCreateStatus.Success:
                foreach (string rol in roles)
                {
                    AddUserToRole(user, rol);
                }

                if (!string.IsNullOrEmpty(roleName))
                {
                    AddUserToRole(user, roleName);
                }
                status = true;
                break;

            case DotNetNuke.Security.Membership.UserCreateStatus.DuplicateEmail:
                throw new Exception("El correo ingresado ya se encuentra registrado en el sistema");

            case DotNetNuke.Security.Membership.UserCreateStatus.DuplicateUserName:
                throw new Exception("El usuario ingresado ya se encuentra registrado en el sistema");

            case DotNetNuke.Security.Membership.UserCreateStatus.DuplicateProviderUserKey:
                throw new Exception("El key ingresado ya se encuentra registrado en el sistema");

            case DotNetNuke.Security.Membership.UserCreateStatus.InvalidEmail:
                throw new Exception("El correo ingresado no es válido");

            case DotNetNuke.Security.Membership.UserCreateStatus.InvalidPassword:
                throw new Exception("La contraseña ingresada no es válida");

            case DotNetNuke.Security.Membership.UserCreateStatus.InvalidUserName:
                throw new Exception("El usuario ingresado no es válido");

            case DotNetNuke.Security.Membership.UserCreateStatus.UserRejected:
                throw new Exception("El usuario ingresado fue rechazado por el sistema");

            default:
                throw new Exception(objUserCreateStatus.ToString());
            }

            return(status);
        }
Exemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            #region ViewPermission
            // Truyen vao tabid va mid de he thong kiem tra
            // Neu User dang truy cap co quyen thi he thong tra ra du lieu
            // Neu user khong co quyen he thong se thong bao not define
            try
            {
                DotNetNuke.Entities.Portals.PortalSettings portalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();
                if (!context.Request.IsAuthenticated)
                {
                    WriteDataError(context, "NotAuthenticated");
                    return;
                }
                // get TabId
                int TabId = Utils.tabCheckCommon;

                // get ModuleId
                int ModuleId = Utils.moduleCheckCommon;

                objUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                DotNetNuke.Entities.Modules.ModuleController mc = new DotNetNuke.Entities.Modules.ModuleController();
                System.Collections.Hashtable settings           = mc.GetModuleSettings(ModuleId);
                objModuleInfo = new DotNetNuke.Entities.Modules.ModuleController().GetModule(ModuleId, TabId);
                if (DotNetNuke.Security.Permissions.ModulePermissionController.CanViewModule(objModuleInfo))
                {
                    try
                    {
                        WriteData(context);
                        return;
                    }
                    catch (Exception ex)
                    {
                        WriteDataError(context, ex.Message);
                        return;
                    }
                }
                else
                {
                    WriteDataError(context, "NotPermission");
                    return;
                }
            }
            catch (Exception ex)
            {
                WriteDataError(context, ex.Message);
                return;
            }
            #endregion
        }
Exemplo n.º 10
0
 public User(DotNetNuke.Entities.Users.UserInfo dnnUser)
 {
     Authorised     = dnnUser.Membership.Approved;
     DisplayName    = dnnUser.DisplayName;
     Email          = dnnUser.Email;
     FirstName      = dnnUser.FirstName;
     IsDeleted      = dnnUser.IsDeleted;
     LastName       = dnnUser.LastName;
     LockedOut      = dnnUser.Membership.LockedOut;
     PortalId       = dnnUser.PortalID;
     UpdatePassword = dnnUser.Membership.UpdatePassword;
     UserId         = dnnUser.UserID;
     Username       = dnnUser.Username;
 }
Exemplo n.º 11
0
        /// <summary>
        /// WindowsAuthorization checks whether the user credentials are valid
        /// Windows credentials
        /// </summary>
        /// <param name="loginStatus">The log in status</param>
        /// <history>
        ///     [cnurse]	03/15/2006
        /// </history>
        private UserInfo WindowsAuthorization(UserLoginStatus loginStatus)
        {
            string strMessage = Null.NullString;

            UserInfo objUser = UserController.GetUserByName(PortalSettings.PortalId, txtUsername.Text, false);
            AuthenticationController objAuthentication = new AuthenticationController();

            DotNetNuke.Security.Authentication.UserInfo objAuthUser = objAuthentication.ProcessFormAuthentication(txtUsername.Text, txtPassword.Text);
            int _userID = -1;

            if ((objAuthUser != null) && (objUser == null))
            {
                // Add this user into DNN database for better performance on next logon
                UserCreateStatus createStatus;
                DotNetNuke.Security.Authentication.UserController objAuthUsers = new DotNetNuke.Security.Authentication.UserController();
                createStatus = objAuthUsers.AddDNNUser(objAuthUser);
                _userID      = objAuthUser.UserID;

                // Windows/DNN password validation should be same, check this status here
                strMessage = UserController.GetUserCreateStatus(createStatus);
            }
            else if ((objAuthUser != null) && (objUser != null))
            {
                // User might has been imported by Admin or automatically added with random password
                // update DNN password to match with authenticated password from AD
                if (objUser.Membership.Password != txtPassword.Text)
                {
                    UserController.ChangePassword(objUser, objUser.Membership.Password, txtPassword.Text);
                }
                _userID = objUser.UserID;
            }

            if (_userID > 0)
            {
                // Authenticated with DNN
                objUser = UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, "", PortalSettings.PortalName, ipAddress, ref loginStatus);
                if (loginStatus != UserLoginStatus.LOGIN_SUCCESS)
                {
                    strMessage = Localization.GetString("LoginFailed", this.LocalResourceFile);
                }
            }
            else
            {
                objUser = null;
            }

            AddLocalizedModuleMessage(strMessage, ModuleMessageType.RedError, !String.IsNullOrEmpty(strMessage));

            return(objUser);
        }
 protected string GetAuthorName(object authorId)
 {
     if (authorId != null)
     {
         string author = string.Empty;
         var    uc     = new DotNetNuke.Entities.Users.UserController();
         DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(authorId, CultureInfo.InvariantCulture));
         if (ui != null)
         {
             author = (authorId is DBNull ? string.Empty : ui.Username);
         }
         return(author);
     }
     return(string.Empty);
 }
Exemplo n.º 13
0
 protected override void RenderContents(HtmlTextWriter writer)
 {
     if (UserId == -1)
     {
         return;
     }
     try
     {
         string output = string.Empty;
         DotNetNuke.Entities.Portals.PortalSettings ps = (DotNetNuke.Entities.Portals.PortalSettings)(Context.Items["PortalSettings"]);
         DotNetNuke.Entities.Users.UserInfo         cu = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
         string imagePath = string.Empty;
         int    portalId  = ps.PortalId;
         string tmp       = string.Empty;
         if (Template == null)
         {
             tmp = "<span class=\"aslabelsmbold\">[RESX:Posts]:</span> [AF:PROFILE:POSTCOUNT]<br />" + "<span class=\"aslabelsmbold\">[RESX:RankName]:</span> [AF:PROFILE:RANKNAME]<br />" + "<span class=\"aslabelsmbold\">[RESX:RankDisplay]:</span> [AF:PROFILE:RANKDISPLAY] <br />" + "<span class=\"aslabelsmbold\">[RESX:LastUpdate]:</span> [AF:PROFILE:DATELASTACTIVITY:d] <br />" + "<span class=\"aslabelsmbold\">[RESX:MemberSince]:</span> [AF:PROFILE:DATECREATED:d]";
         }
         else
         {
             tmp = Template.Text;
         }
         if (ModuleId == -1)
         {
             DotNetNuke.Entities.Modules.ModuleController mc = new DotNetNuke.Entities.Modules.ModuleController();
             DotNetNuke.Entities.Tabs.TabController       tc = new DotNetNuke.Entities.Tabs.TabController();
             DotNetNuke.Entities.Tabs.TabInfo             ti = null;
             foreach (DotNetNuke.Entities.Modules.ModuleInfo mi in mc.GetModules(portalId))
             {
                 if (mi.DesktopModule.ModuleName.ToUpperInvariant() == "Active Forums".ToUpperInvariant())
                 {
                     ModuleId = mi.ModuleID;
                     break;
                 }
             }
         }
         output = TemplateUtils.ParseProfileTemplate(tmp, UserId, portalId, ModuleId, cu.UserID, Convert.ToInt32(PortalSettings.Current.TimeZone.BaseUtcOffset.TotalMinutes));
         output = Utilities.LocalizeControl(output);
         writer.Write(output);
     }
     catch (Exception ex)
     {
         writer.Write(ex.Message);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// PasswordUpdated runs when the password is updated
        /// </summary>
        /// <history>
        ///     [cnurse]	03/15/2006  Created
        /// </history>
        protected void PasswordUpdated(object sender, Password.PasswordUpdatedEventArgs e)
        {
            PasswordUpdateStatus status = e.UpdateStatus;

            if (status == PasswordUpdateStatus.Success)
            {
                AddModuleMessage("PasswordChanged", ModuleMessageType.GreenSuccess, true);

                //Authorize User
                UserInfo _User = ctlPassword.User;
                _User.Membership.LastPasswordChangeDate = DateTime.Now;
                _User.Membership.UpdatePassword         = false;
                UserAuthorized(_User, true);
            }
            else
            {
                AddModuleMessage(status.ToString(), ModuleMessageType.RedError, true);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Para que esto funcione tiene que estar enablePasswordRetrieval="true" y passwordFormat="Encrypted".
        /// Los usuarios
        /// </summary>
        /// <param name="PortalID"> El portal ID donde esta el user</param>
        /// <param name="UserID"> El userID del cual queres la password</param>
        /// <returns></returns>
        private static string GetPassword(int PortalID, int UserID)
        {
            if (UserID == -1)
            {
                return(string.Empty);
            }                                        // No esta logueado
            try
            {
                DotNetNuke.Entities.Users.UserInfo uInfo = DotNetNuke.Entities.Users.UserController.GetUserById(PortalID, UserID);
                string password = DotNetNuke.Entities.Users.UserController.GetPassword(ref uInfo, String.Empty);
                return(password);
            }


            catch (Exception Ex)
            {
                throw new Exception("Exception at WSManager GetPassword. Exception says: " + Ex.Message, Ex);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string sDisplayName = string.Empty;
            int    tUid         = -1;

            if (Request.Params["UID"] != null)
            {
                if (SimulateIsNumeric.IsNumeric(Request.Params["UID"]))
                {
                    tUid = Convert.ToInt32(Request.Params["UID"]);
                    DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                    DotNetNuke.Entities.Users.UserInfo       ui = uc.GetUser(PortalId, tUid);
                    if (ui != null)
                    {
                        sDisplayName = UserProfiles.GetDisplayName(ModuleId, ui.UserID, ui.Username, ui.FirstName, ui.LastName, ui.DisplayName);
                    }
                }
            }
            else
            {
                tUid         = UserId;
                sDisplayName = UserProfiles.GetDisplayName(ModuleId, UserId, UserInfo.Username, UserInfo.FirstName, UserInfo.LastName, UserInfo.DisplayName);
            }
            lblHeader.Text = string.Format(Utilities.GetSharedResource("[RESX:ProfileForUser]"), sDisplayName);
            if (MainSettings.UseSkinBreadCrumb)
            {
                Environment.UpdateBreadCrumb(Page.Controls, "<a href=\"" + Utilities.NavigateUrl(TabId, "", new string[] { "afv=profile", "uid=" + tUid.ToString() }) + "\">" + lblHeader.Text + "</a>");
            }
            DotNetNuke.Framework.CDefault tempVar = this.BasePage;
            Environment.UpdateMeta(ref tempVar, "[VALUE] - " + lblHeader.Text, "[VALUE]", "[VALUE]");
            SettingsBase ctl = null;

            ctl = (SettingsBase)(new DotNetNuke.Modules.ActiveForums.Controls.UserProfile());
            ctl.ModuleConfiguration = this.ModuleConfiguration;
            if (!(this.Params == string.Empty))
            {
                ctl.Params = this.Params;
            }
            plhProfile.Controls.Add(ctl);
        }
Exemplo n.º 17
0
        /// <summary>
        /// get current logged user profile property value, for property named pname
        /// </summary>
        /// <param name="pname"></param>
        /// <returns></returns>
        public string GetUserProfileProperty(string pname)
        {
            try
            {
                DotNetNuke.Entities.Users.UserInfo ui = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                string pval = ui.Profile.GetPropertyValue(pname);

                if (pval != "" && pval != null)
                {
                    return(pval);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception)
            {
                return("");
            }
        }
Exemplo n.º 18
0
        public void ProcessRequest(HttpContext context)
        {
            #region ViewPermission
            try
            {
                if (!context.Request.IsAuthenticated)
                {
                    WriteDataError(context, "NotAuthenticated");
                    return;
                }

                objUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                string Role = "CTSV";
                if (checkRole(objUserInfo.Roles, Role))
                {
                    try
                    {
                        WriteData(context);
                        return;
                    }
                    catch (Exception ex)
                    {
                        WriteDataError(context, ex.Message);
                        return;
                    }
                }
                else
                {
                    WriteDataError(context, "NotPermission");
                    return;
                }
            }
            catch (Exception ex)
            {
                WriteDataError(context, ex.Message);
                return;
            }
            #endregion
        }
Exemplo n.º 19
0
        public static UserNames GetUserNamesData(long portalKey, long userKey)
        {
            if (portalKey != 0) // right now we only support caching on the main portal.  Could easily expand this.
            {
                throw new CacheException("Only Portal '0' supports caching in this version");
            }
            if (UserNameMap.ContainsKey(userKey))
            {
                return(UserNameMap[userKey]);
            }
            DotNetNuke.Entities.Users.UserInfo uinfo = DotNetNuke.Entities.Users.UserController.GetUser((int)portalKey, (int)userKey, false); // false does not hydrate user ROLES
            UserNames unames = new UserNames()
            {
                FirstName    = uinfo.FirstName,
                LastName     = uinfo.LastName,
                CombinedName = uinfo.FirstName + " " + uinfo.LastName.ToUpper()[0] + ".",
                Email        = uinfo.Email,
                UserName     = uinfo.Username
            };

            UserNameMap.Add(userKey, unames);
            return(unames);
        }
Exemplo n.º 20
0
        public Paciente InsertHistory(string Historial, int IdUser, int IdPortal, string UIPaciente)
        {
            Paciente p   = new Paciente("error", "error", DateTime.Now, "error", "error", "error", "error", 0, "error", "error", false);
            Paciente t_P = ConnectionDispensario.Modelos.Paciente.Select_Paciente_by_GUI(UIPaciente);

            if (t_P != null)
            {
                DotNetNuke.Entities.Users.UserController UC   = new DotNetNuke.Entities.Users.UserController();
                DotNetNuke.Entities.Users.UserInfo       t_UI = UC.GetUser(IdPortal, IdUser);
                if (t_UI != null)
                {
                    Historial H = new Historial(Historial.Replace("\n", "[LineJump]"), IdUser, t_P.ID);
                    if (H.Guardar() == true)
                    {
                        ConnectionDispensario.Statics.LogCatcher.AddLog("Se inserto correctamente", "Se inserto correctamente", null, null);
                        return(t_P);
                    }
                    else
                    {
                        ConnectionDispensario.Statics.LogCatcher.AddLog("No se pudo Guardar", "No se pudo Guardar", null, null);
                        return(p);
                    }
                }
                else
                {
                    ConnectionDispensario.Statics.LogCatcher.AddLog("No existe el usuario", "No existe el usuario", null, null);
                    return(p);
                }
            }
            else
            {
                ConnectionDispensario.Statics.LogCatcher.AddLog("No existe el Paciente", "No existe el Paciente", null, null);


                return(p);
            }
        }
Exemplo n.º 21
0
        private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            SettingsInfo ms = DataCache.MainSettings(ForumModuleId);
            Forum        fi = null;

            if (e.Parameters.Length > 0)
            {
                if (ForumId < 1)
                {
                    SetPermissions(Convert.ToInt32(e.Parameters[1]));
                    ForumController fc = new ForumController();
                    fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true);
                }
                else
                {
                    fi = ForumInfo;
                }
                switch (e.Parameters[0].ToLowerInvariant())
                {
                case "moddel":
                {
                    if (bModDelete)
                    {
                        int delAction  = ms.DeleteBehavior;
                        int tmpForumId = -1;
                        int tmpTopicId = -1;
                        int tmpReplyId = -1;
                        tmpForumId = Convert.ToInt32(e.Parameters[1]);
                        tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                        tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                        Author auth = null;
                        if (fi.ModDeleteTemplateId > 0)
                        {
                            try
                            {
                                //Email.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth);
                                Email.SendEmailToModerators(fi.ModDeleteTemplateId, PortalId, tmpForumId, tmpTopicId, tmpReplyId, ForumModuleId, ForumTabId, string.Empty);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                        {
                            TopicsController tc = new TopicsController();
                            TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId);
                            if (ti != null)
                            {
                                auth = ti.Author;
                            }
                            tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction);
                        }
                        else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                        {
                            ReplyController rc = new ReplyController();
                            ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                            if (ri != null)
                            {
                                auth = ri.Author;
                            }
                            rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction);
                        }
                    }
                    break;
                }

                case "modreject":
                {
                    int tmpForumId  = 0;
                    int tmpTopicId  = 0;
                    int tmpReplyId  = 0;
                    int tmpAuthorId = 0;
                    tmpForumId  = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId  = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId  = Convert.ToInt32(e.Parameters[3]);
                    tmpAuthorId = Convert.ToInt32(e.Parameters[4]);
                    ModController mc = new ModController();
                    mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId);
                    if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0)
                    {
                        DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                        DotNetNuke.Entities.Users.UserInfo       ui = uc.GetUser(PortalId, tmpAuthorId);
                        if (ui != null)
                        {
                            Author au = new Author();
                            au.AuthorId    = tmpAuthorId;
                            au.DisplayName = ui.DisplayName;
                            au.Email       = ui.Email;
                            au.FirstName   = ui.FirstName;
                            au.LastName    = ui.LastName;
                            au.Username    = ui.Username;
                            Email.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au);
                        }
                    }

                    break;
                }

                case "modappr":
                {
                    int tmpForumId = -1;
                    int tmpTopicId = -1;
                    int tmpReplyId = -1;
                    tmpForumId = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                    string sSubject = string.Empty;
                    string sBody    = string.Empty;
                    if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                    {
                        TopicsController tc = new TopicsController();
                        TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                        if (ti != null)
                        {
                            sSubject      = ti.Content.Subject;
                            sBody         = ti.Content.Body;
                            ti.IsApproved = true;
                            tc.TopicSave(PortalId, ti);
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       sUrl     = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId)
                                if (sUrl.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId);
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled)
                                {
                                    amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }
                    else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                    {
                        ReplyController rc = new ReplyController();
                        ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                        if (ri != null)
                        {
                            ri.IsApproved = true;
                            sSubject      = ri.Content.Subject;
                            sBody         = ri.Content.Body;
                            rc.Reply_Save(PortalId, ri);
                            TopicsController tc = new TopicsController();
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId);
                            TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       fullURL  = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId);
                                if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly)
                                {
                                    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }


                    break;
                }
                }
                string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
            }
            BuildModList();
            litTopics.RenderControl(e.Output);
        }
Exemplo n.º 22
0
        public override string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "timezoneid": // VarChar
                if (TimeZoneId == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(TimeZoneId, strFormat));

            case "sessiondateandtime": // DateTime
                if (SessionDateAndTime == null)
                {
                    return("");
                }
                ;
                return(((DateTime)SessionDateAndTime).ToString(strFormat, formatProvider));

            case "sessionend": // DateTime
                if (SessionEnd == null)
                {
                    return("");
                }
                ;
                return(((DateTime)SessionEnd).ToString(strFormat, formatProvider));

            case "locationname": // NVarChar
                if (LocationName == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(LocationName, strFormat));

            case "slottitle": // NVarChar
                if (SlotTitle == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(SlotTitle, strFormat));

            case "tracktitle": // NVarChar
                if (TrackTitle == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(TrackTitle, strFormat));

            case "backgroundcolor": // NVarChar
                if (BackgroundColor == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(BackgroundColor, strFormat));

            case "nrattendees": // Int
                if (NrAttendees == null)
                {
                    return("");
                }
                ;
                return(((int)NrAttendees).ToString(strFormat, formatProvider));

            case "nrspeakers": // Int
                if (NrSpeakers == null)
                {
                    return("");
                }
                ;
                return(((int)NrSpeakers).ToString(strFormat, formatProvider));

            case "nrvotes": // Int
                if (NrVotes == null)
                {
                    return("");
                }
                ;
                return(((int)NrVotes).ToString(strFormat, formatProvider));

            case "nrresources": // Int
                if (NrResources == null)
                {
                    return("");
                }
                ;
                return(((int)NrResources).ToString(strFormat, formatProvider));

            case "createdbyuser": // NVarChar
                if (CreatedByUser == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(CreatedByUser, strFormat));

            case "lastmodifiedbyuser": // NVarChar
                if (LastModifiedByUser == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(LastModifiedByUser, strFormat));

            default:
                return(base.GetProperty(strPropertyName, strFormat, formatProvider, accessingUser, accessLevel, ref propertyNotFound));
            }
        }
        public virtual string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "namespaceid": // Int
                return(NamespaceId.ToString(strFormat, formatProvider));

            case "parentid": // Int
                return(ParentId.ToString(strFormat, formatProvider));

            case "moduleid": // Int
                return(ModuleId.ToString(strFormat, formatProvider));

            case "namespacename": // NVarChar
                return(PropertyAccess.FormatString(NamespaceName, strFormat));

            case "lastqualifier": // NVarChar
                return(PropertyAccess.FormatString(LastQualifier, strFormat));

            case "description": // NVarCharMax
                if (Description == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Description, strFormat));

            default:
                propertyNotFound = true;
                break;
            }

            return(Null.NullString);
        }
Exemplo n.º 24
0
        public override string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "createdbyuserdisplayname": // NVarChar
                if (CreatedByUserDisplayName == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(CreatedByUserDisplayName, strFormat));

            case "lastmodifiedbyuserdisplayname": // NVarChar
                if (LastModifiedByUserDisplayName == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(LastModifiedByUserDisplayName, strFormat));

            case "documentationcontents": // NVarCharMax
                if (DocumentationContents == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(DocumentationContents, strFormat));

            case "classname": // NVarChar
                return(PropertyAccess.FormatString(ClassName, strFormat));

            case "namespacename": // NVarChar
                return(PropertyAccess.FormatString(NamespaceName, strFormat));

            case "fullqualifier": // NVarChar
                return(PropertyAccess.FormatString(FullQualifier, strFormat));

            case "moduleid": // Int
                return(ModuleId.ToString(strFormat, formatProvider));

            case "componentname": // NVarChar
                return(PropertyAccess.FormatString(ComponentName, strFormat));

            case "latestversion": // VarChar
                return(PropertyAccess.FormatString(LatestVersion, strFormat));

            case "codeblockcount": // Int
                if (CodeBlockCount == null)
                {
                    return("");
                }
                ;
                return(((int)CodeBlockCount).ToString(strFormat, formatProvider));

            default:
                return(base.GetProperty(strPropertyName, strFormat, formatProvider, accessingUser, accessLevel, ref propertyNotFound));
            }
        }
Exemplo n.º 25
0
        public override string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "displayname": // NVarChar
                return(PropertyAccess.FormatString(DisplayName, strFormat));

            case "firstname": // NVarChar
                return(PropertyAccess.FormatString(FirstName, strFormat));

            case "lastname": // NVarChar
                return(PropertyAccess.FormatString(LastName, strFormat));

            case "email": // NVarChar
                if (Email == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Email, strFormat));

            case "username": // NVarChar
                return(PropertyAccess.FormatString(Username, strFormat));

            case "photovisibility": // Int
                if (PhotoVisibility == null)
                {
                    return("");
                }
                ;
                return(((int)PhotoVisibility).ToString(strFormat, formatProvider));

            case "photofilename": // NVarChar
                if (PhotoFilename == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(PhotoFilename, strFormat));

            case "photofolder": // NVarChar
                if (PhotoFolder == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(PhotoFolder, strFormat));

            case "photowidth": // Int
                if (PhotoWidth == null)
                {
                    return("");
                }
                ;
                return(((int)PhotoWidth).ToString(strFormat, formatProvider));

            case "photoheight": // Int
                if (PhotoHeight == null)
                {
                    return("");
                }
                ;
                return(((int)PhotoHeight).ToString(strFormat, formatProvider));

            case "photocontenttype": // NVarChar
                if (PhotoContentType == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(PhotoContentType, strFormat));

            case "biography": // NVarChar
                if (Biography == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Biography, strFormat));

            case "createdbyuser": // NVarChar
                if (CreatedByUser == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(CreatedByUser, strFormat));

            case "lastmodifiedbyuser": // NVarChar
                if (LastModifiedByUser == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(LastModifiedByUser, strFormat));

            default:
                return(base.GetProperty(strPropertyName, strFormat, formatProvider, accessingUser, accessLevel, ref propertyNotFound));
            }
        }
Exemplo n.º 26
0
 public override void RemoveUserFromRole(int portalId, DotNetNuke.Entities.Users.UserInfo user, DotNetNuke.Entities.Users.UserRoleInfo userRole)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 27
0
 public override bool AddUserToRole(int portalId, DotNetNuke.Entities.Users.UserInfo user, DotNetNuke.Entities.Users.UserRoleInfo userRole)
 {
     throw new NotImplementedException();
 }
        public virtual string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "locationid": // Int
                return(LocationId.ToString(strFormat, formatProvider));

            case "conferenceid": // Int
                return(ConferenceId.ToString(strFormat, formatProvider));

            case "name": // NVarChar
                if (Name == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Name, strFormat));

            case "description": // NVarCharMax
                if (Description == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Description, strFormat));

            case "capacity": // Int
                if (Capacity == null)
                {
                    return("");
                }
                ;
                return(((int)Capacity).ToString(strFormat, formatProvider));

            case "sort": // Int
                if (Sort == null)
                {
                    return("");
                }
                ;
                return(((int)Sort).ToString(strFormat, formatProvider));

            case "backgroundcolor": // NVarChar
                if (BackgroundColor == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(BackgroundColor, strFormat));

            default:
                propertyNotFound = true;
                break;
            }

            return(Null.NullString);
        }
Exemplo n.º 29
0
        public override string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "membername": // VarChar
                if (MemberName == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(MemberName, strFormat));

            case "appearedinversion": // VarChar
                if (AppearedInVersion == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(AppearedInVersion, strFormat));

            case "deprecatedinversion": // VarChar
                if (DeprecatedInVersion == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(DeprecatedInVersion, strFormat));

            case "disappearedinversion": // VarChar
                if (DisappearedInVersion == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(DisappearedInVersion, strFormat));

            default:
                return(base.GetProperty(strPropertyName, strFormat, formatProvider, accessingUser, accessLevel, ref propertyNotFound));
            }
        }
Exemplo n.º 30
0
        public string GetNewGrid()
        {
            //Roles
            string[] roles   = GetSecureObjectList(Security, 0).Split(';');
            int[]    roleIds = new int[roles.Length - 2 + 1];
            int      i       = 0;

            for (i = 0; i <= roles.Length - 2; i++)
            {
                if (!(string.IsNullOrEmpty(roles[i])))
                {
                    roleIds[i] = Convert.ToInt32(roles[i]);
                }
            }
            Array.Sort(roleIds);
            string tmp = string.Empty;

            foreach (int n in roleIds)
            {
                tmp += n.ToString() + ";";
            }
            List <PermissionInfo> pl = new List <PermissionInfo>();

            //litNewGrid.Text = "Roles:" & tmp

            //litNewGrid.Text &= "<br />RolesNames:" & Permissions.GetRolesNVC(tmp)
            NameValueCollection nvc = Permissions.GetRolesNVC(tmp, PortalId);

            foreach (string key in nvc.AllKeys)
            {
                PermissionInfo pi = new PermissionInfo();
                pi.ObjectId   = key;
                pi.ObjectName = nvc[key];
                pi.Type       = ObjectType.RoleId;
                pl.Add(pi);
            }

            //Users
            string users     = GetSecureObjectList(Security, 1);
            string userNames = string.Empty;

            if (!(string.IsNullOrEmpty(users)))
            {
                DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                foreach (string uid in users.Split(';'))
                {
                    if (!(string.IsNullOrEmpty(uid)))
                    {
                        DotNetNuke.Entities.Users.UserInfo u = uc.GetUser(PortalId, Convert.ToInt32(uid));
                        if (u != null)
                        {
                            PermissionInfo pi = new PermissionInfo();
                            pi.ObjectId   = u.UserID.ToString();
                            pi.ObjectName = u.DisplayName;
                            pi.Type       = ObjectType.UserId;
                            pl.Add(pi);
                        }
                    }
                }
            }
            //Groups
            string groups = GetSecureObjectList(Security, 2);

            if (!(string.IsNullOrEmpty(groups)))
            {
                foreach (string g in groups.Split(';'))
                {
                    if (!(string.IsNullOrEmpty(g)))
                    {
                        Social uc        = new Social();
                        string gType     = g.Split(':')[1];
                        int    groupId   = Convert.ToInt32(g.Split(':')[0]);
                        string groupName = uc.ActiveSocialGetGroup(groupId);
                        if (!(string.IsNullOrEmpty(groupName)))
                        {
                            PermissionInfo pi = new PermissionInfo();
                            pi.ObjectId    = g;
                            pi.ObjectName  = groupName;
                            pi.Type        = ObjectType.GroupId;
                            pi.ObjectName += "-" + uc.ActiveSocialGetGroupType(Convert.ToInt32(gType), PortalId);
                            pl.Add(pi);
                        }
                    }
                }
            }

            string[,] grid = new string[pl.Count + 1, 28];
            i = 0;
            foreach (PermissionInfo pi in pl)
            {
                grid[i, 0]  = pi.ObjectId;
                grid[i, 1]  = pi.ObjectName;
                grid[i, 2]  = Convert.ToString(pi.Type);
                grid[i, 3]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.View));
                grid[i, 4]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Read));
                grid[i, 5]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Create));
                grid[i, 6]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Reply));
                grid[i, 7]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Edit));
                grid[i, 8]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Delete));
                grid[i, 9]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Lock));
                grid[i, 10] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Pin));
                grid[i, 11] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Attach));
                grid[i, 12] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Poll));
                grid[i, 13] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Block));
                grid[i, 14] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Trust));
                grid[i, 15] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Subscribe));
                grid[i, 16] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Announce));
                grid[i, 17] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Tag));
                grid[i, 18] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Categorize));
                grid[i, 19] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Prioritize));

                grid[i, 20] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModApprove));
                grid[i, 21] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModMove));
                grid[i, 22] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModSplit));
                grid[i, 23] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModDelete));
                grid[i, 24] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModUser));
                grid[i, 25] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModEdit));
                grid[i, 26] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModLock));
                grid[i, 27] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModPin));


                i += 1;
            }
            System.Type   enumType = typeof(SecureActions);
            Array         values   = Enum.GetValues(enumType);
            StringBuilder sb       = new StringBuilder();

            sb.Append("<table cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\"><div class=\"afsecobjects\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
            sb.Append("<tr><td class=\"afsecobjecthd\" colspan=\"2\">" + Utilities.GetSharedResource("[RESX:SecureObjects]", true) + "</td></tr>");
            string tmpObjectName = string.Empty;
            int    secRows       = 0;

            for (int x = 0; x < pl.Count; x++)
            {
                sb.Append("<tr><td style=\"width:16px;\"></td><td class=\"afsecobject\" style=\"white-space:nowrap;\"><div class=\"afsecobjecttxt\" title=\"" + grid[x, 1] + "\" onmouseover=\"this.firstChild.style.display='';\" onmouseout=\"this.firstChild.style.display='none';\"><span style=\"width:16px;height:16px;float:right;display:none;\">");
                if ((Convert.ToInt32(grid[x, 2]) == 0 && Convert.ToInt32(grid[x, 0]) > 0) | Convert.ToInt32(grid[x, 2]) > 0)
                {
                    if (!ReadOnly)
                    {
                        sb.Append("<img src=\"" + ImagePath + "mini_del.gif\" alt=\"Remove Object\" style=\"cursor:pointer;z-index:10;\" class=\"afminidel\" onclick=\"securityDelObject(this,'" + grid[x, 0] + "'," + grid[x, 2] + "," + PermissionsId + ");\" />");
                    }
                }
                sb.Append("</span>" + grid[x, 1]);
                sb.Append("</div></td></tr>");
            }
            sb.Append("</table></div></td><td valign=\"top\" width=\"94%\"><div class=\"afsecactions\" style=\"overflow-x:auto;overflow-y:hidden;\">");
            //litNewObjects.Text = sb.ToString
            //sb = New StringBuilder

            sb.Append("<table cellpadding=0 cellspacing=0 border=0 width=\"100%\" id=\"tblSecGrid\">");
            sb.Append("<tr>");
            string keyText = string.Empty;

            for (int td = 3; td <= 27; td++)
            {
                keyText = Convert.ToString(Enum.Parse(enumType, values.GetValue(td - 3).ToString()));
                if (keyText.ToLowerInvariant() == "block")
                {
                    sb.Append("<td class=\"afsecactionhd\" style=\"display:none;\">");
                }
                else
                {
                    sb.Append("<td class=\"afsecactionhd\">");
                }


                sb.Append(keyText);
                sb.Append("</td>");
            }
            sb.Append("</tr>");
            for (int x = 0; x < pl.Count; x++)
            {
                sb.Append("<tr onmouseover=\"this.className='afgridrowover'\" onmouseout=\"this.className='afgridrow'\">");
                for (int r = 3; r <= 27; r++)
                {
                    keyText = Convert.ToString(Enum.Parse(enumType, values.GetValue(r - 3).ToString()));
                    bool   bState = Convert.ToBoolean(grid[x, r]);                   //Permissions.HasPermission(ForumID, Integer.Parse(dr("ObjectId").ToString), key, Integer.Parse(dr("SecureType").ToString), dt)
                    string sState = "<img src=\"" + ImagePath + "admin_stop.png\" alt=\"Disabled\" />";
                    if (bState)
                    {
                        sState = "<img src=\"" + ImagePath + "admin_check.png\" alt=\"Enabled\" />";
                    }
                    if (keyText.ToLowerInvariant() == "block")
                    {
                        sb.Append("<td class=\"afsecactionelem\" style=\"text-align:center;display:none;\">");
                    }
                    else
                    {
                        sb.Append("<td class=\"afsecactionelem\" style=\"text-align:center;\">");
                    }

                    sb.Append("<div class=\"afsectoggle\" id=\"" + grid[x, 0] + grid[x, 2] + keyText + "\" ");
                    if (!ReadOnly)
                    {
                        sb.Append("onclick=\"securityToggle(this," + PermissionsId + ",'" + grid[x, 0] + "','" + grid[x, 1] + "'," + grid[x, 2] + ",'" + keyText + "');\"");
                    }
                    sb.Append(">" + sState + "</div></td>");
                }
                sb.Append("</tr>");
            }
            sb.Append("</table></div></td></tr></table>");
            return(sb.ToString());
        }
Exemplo n.º 31
0
        /// <summary>
        /// UserAuthorized runs when the user has been authorized by the data store
        /// </summary>
        /// <param name="objUser">The logged in User</param>
        /// <history>
        /// 	[cnurse]	03/15/2006
        /// </history>
        ///<param name="canProceed"></param>
        private void UserAuthorized( UserInfo objUser, bool canProceed )
        {
            bool updatePassword = false;
            bool updateProfile = false;
            string strMessage;

            UserId = objUser.UserID;

            //Set the Page Culture(Language) based on the Users Preferred Locale
            if( ( objUser.Profile != null ) && ( objUser.Profile.PreferredLocale != null ) )
            {
                Localization.SetLanguage( objUser.Profile.PreferredLocale );
            }
            else
            {
                Localization.SetLanguage( PortalSettings.DefaultLanguage );
            }

            //Check whether Password needs updating
            if( PasswordConfig.PasswordExpiry > 0 )
            {
                DateTime expiryDate = objUser.Membership.LastPasswordChangeDate.AddDays( PasswordConfig.PasswordExpiry );
                if( expiryDate < DateTime.Today )
                {
                    //Password Expired
                    strMessage = string.Format( Localization.GetString( "PasswordExpired", this.LocalResourceFile ), expiryDate.ToLongDateString(), null );
                    AddLocalizedModuleMessage( strMessage, ModuleMessageType.YellowWarning, true );
                    updatePassword = true;
                    pnlProceed.Visible = false;
                }
                if( ( ! updatePassword ) && expiryDate < DateTime.Today.AddDays( PasswordConfig.PasswordExpiryReminder ) )
                {
                    //Password update reminder
                    strMessage = string.Format( Localization.GetString( "PasswordExpiring", this.LocalResourceFile ), expiryDate.ToLongDateString(), null );
                    AddLocalizedModuleMessage( strMessage, ModuleMessageType.YellowWarning, true );
                    updatePassword = ! canProceed;
                    pnlProceed.Visible = true;
                }
            }
            if( ( ! updatePassword ) && objUser.Membership.UpdatePassword )
            {
                //Admin has forced password update
                AddModuleMessage( "PasswordUpdate", ModuleMessageType.YellowWarning, true );
                updatePassword = true;
            }

            //Check whether Profile needs updating
            if( ! updatePassword && this.RequireValidProfile )
            {
                //Admin has forced password update
                AddModuleMessage( "ProfileUpdate", ModuleMessageType.YellowWarning, true );
                updateProfile = ! ProfileController.ValidateProfile( PortalId, objUser.Profile );
            }

            if( updatePassword )
            {
                PageNo = 1;
            }
            else if( updateProfile )
            {
                //Admin has forced profile update
                AddModuleMessage( "ProfileUpdate", ModuleMessageType.YellowWarning, true );
                PageNo = 2;
            }
            else
            {
                //Complete Login
                UserController.UserLogin( PortalId, objUser, PortalSettings.PortalName, ipAddress, chkCookie.Checked );

                // redirect browser
                Response.Redirect( RedirectURL, true );
            }

            ShowPanel();
        }