当前位置: 首页>>代码示例>>C#>>正文


C# RoleController.UpdateRole方法代码示例

本文整理汇总了C#中DotNetNuke.Security.Roles.RoleController.UpdateRole方法的典型用法代码示例。如果您正苦于以下问题:C# RoleController.UpdateRole方法的具体用法?C# RoleController.UpdateRole怎么用?C# RoleController.UpdateRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Security.Roles.RoleController的用法示例。


在下文中一共展示了RoleController.UpdateRole方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApproveGroup

        public ActionResult ApproveGroup(int notificationId)
        {
            try
            {
                var recipient = InternalMessagingController.Instance.GetMessageRecipient(notificationId, UserInfo.UserID);
                if (recipient == null) return Json(new { Result = "error" });

                var notification = NotificationsController.Instance.GetNotification(notificationId);
                ParseKey(notification.Context);
                if (roleInfo == null)
                {
                    return Json(new { Result = "error" });
                }
                if (!IsMod())
                {
                    return Json(new { Result = "access denied" });
                }
                var roleController = new RoleController();
                roleInfo.Status = RoleStatus.Approved;
                roleController.UpdateRole(roleInfo);
                var roleCreator = UserController.GetUserById(PortalSettings.PortalId, roleInfo.CreatedByUserID);
                //Update the original creator's role
                roleController.UpdateUserRole(PortalSettings.PortalId, roleCreator.UserID, roleInfo.RoleID, RoleStatus.Approved, true, false);
                GroupUtilities.CreateJournalEntry(roleInfo, roleCreator);

                var notifications = new Notifications();
                var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId);
                notifications.AddGroupNotification(Constants.GroupApprovedNotification, TabId, ModuleId, roleInfo, siteAdmin, new List<RoleInfo> { roleInfo });
                NotificationsController.Instance.DeleteAllNotificationRecipients(notificationId);

                return Json(new { Result = "success" });
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
                return Json(new { Result = "error" });
            }
        }
开发者ID:biganth,项目名称:Curt,代码行数:38,代码来源:GroupServices.cs

示例2: ApproveGroup

        public HttpResponseMessage ApproveGroup(NotificationDTO postData)
        {
            try
            {
                var recipient = InternalMessagingController.Instance.GetMessageRecipient(postData.NotificationId, UserInfo.UserID);
                if (recipient == null) return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate recipient");

                var notification = NotificationsController.Instance.GetNotification(postData.NotificationId);
                ParseKey(notification.Context);
                if (_roleInfo == null)
                {
                    return  Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate role");
                }
                if (!IsMod())
                {
                    return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized!");
                }
                var roleController = new RoleController();
                _roleInfo.Status = RoleStatus.Approved;
                roleController.UpdateRole(_roleInfo);
                var roleCreator = UserController.GetUserById(PortalSettings.PortalId, _roleInfo.CreatedByUserID);
                //Update the original creator's role
                roleController.UpdateUserRole(PortalSettings.PortalId, roleCreator.UserID, _roleInfo.RoleID, RoleStatus.Approved, true, false);
                GroupUtilities.CreateJournalEntry(_roleInfo, roleCreator);

                var notifications = new Notifications();
                var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId);
                notifications.AddGroupNotification(Constants.GroupApprovedNotification, _tabId, _moduleId, _roleInfo, siteAdmin, new List<RoleInfo> { _roleInfo });
                NotificationsController.Instance.DeleteAllNotificationRecipients(postData.NotificationId);

                return Request.CreateResponse(HttpStatusCode.OK, new {Result = "success"});
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
            }
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:38,代码来源:ModerationServiceController.cs

示例3: JoinGroup

        public HttpResponseMessage JoinGroup(RoleDTO postData)
        {
            try
            {
                if (UserInfo.UserID >= 0 && postData.RoleId > 0)
                {
                    var roleController = new RoleController();
                    _roleInfo = roleController.GetRole(postData.RoleId, PortalSettings.PortalId);
                    if (_roleInfo != null)
                    {

                        var requireApproval = false;

                        if(_roleInfo.Settings.ContainsKey("ReviewMembers"))
                            requireApproval = Convert.ToBoolean(_roleInfo.Settings["ReviewMembers"]);


                        if ((_roleInfo.IsPublic || UserInfo.IsInRole(PortalSettings.AdministratorRoleName)) && !requireApproval)
                        {
                            roleController.AddUserRole(PortalSettings.PortalId, UserInfo.UserID, _roleInfo.RoleID, Null.NullDate);
                            roleController.UpdateRole(_roleInfo);

                            var url = Globals.NavigateURL(postData.GroupViewTabId, "", new[] { "groupid=" + _roleInfo.RoleID });
                            return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success", URL = url });
                        
                        }
                        if (_roleInfo.IsPublic && requireApproval)
                        {
                            roleController.AddUserRole(PortalSettings.PortalId, UserInfo.UserID, _roleInfo.RoleID, RoleStatus.Pending, false, Null.NullDate, Null.NullDate);
                            var notifications = new Notifications();
                            notifications.AddGroupOwnerNotification(Constants.MemberPendingNotification, _tabId, _moduleId, _roleInfo, UserInfo);
                            return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success", URL = string.Empty });
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
            }

            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unknown Error");
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:44,代码来源:ModerationServiceController.cs

示例4: OnUpdateClick

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the update Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// 	[jlucarino]	2/23/2009	Added CreatedByUserID and LastModifiedByUserID
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    float sglServiceFee = 0;
                    var intBillingPeriod = 1;
                    var strBillingFrequency = "N";

                    if (cboBillingFrequency.SelectedItem.Value == "N" && !String.IsNullOrEmpty(txtServiceFee.Text))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("IncompatibleFee", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }
                    if (!String.IsNullOrEmpty(txtServiceFee.Text) && !String.IsNullOrEmpty(txtBillingPeriod.Text) && cboBillingFrequency.SelectedItem.Value != "N")
                    {
                        sglServiceFee = float.Parse(txtServiceFee.Text);
                        intBillingPeriod = int.Parse(txtBillingPeriod.Text);
                        strBillingFrequency = cboBillingFrequency.SelectedItem.Value;
                    }
                    float sglTrialFee = 0;
                    var intTrialPeriod = 1;
                    var strTrialFrequency = "N";

                    if (sglServiceFee != 0 && !String.IsNullOrEmpty(txtTrialFee.Text) && !String.IsNullOrEmpty(txtTrialPeriod.Text) && cboTrialFrequency.SelectedItem.Value != "N")
                    {
                        sglTrialFee = float.Parse(txtTrialFee.Text);
                        intTrialPeriod = int.Parse(txtTrialPeriod.Text);
                        strTrialFrequency = cboTrialFrequency.SelectedItem.Value;
                    }
                    var objRoleController = new RoleController();
                    var objRoleInfo = new RoleInfo();
                    objRoleInfo.PortalID = PortalId;
                    objRoleInfo.RoleID = _roleID;
                    objRoleInfo.RoleGroupID = int.Parse(cboRoleGroups.SelectedValue);
                    objRoleInfo.RoleName = txtRoleName.Text;
                    objRoleInfo.Description = txtDescription.Text;
                    objRoleInfo.ServiceFee = sglServiceFee;
                    objRoleInfo.BillingPeriod = intBillingPeriod;
                    objRoleInfo.BillingFrequency = strBillingFrequency;
                    objRoleInfo.TrialFee = sglTrialFee;
                    objRoleInfo.TrialPeriod = intTrialPeriod;
                    objRoleInfo.TrialFrequency = strTrialFrequency;
                    objRoleInfo.IsPublic = chkIsPublic.Checked;
                    objRoleInfo.AutoAssignment = chkAutoAssignment.Checked;
                    objRoleInfo.RSVPCode = txtRSVPCode.Text;
                    objRoleInfo.IconFile = ctlIcon.Url;
                    if (_roleID == -1)
                    {
                        if (objRoleController.GetRoleByName(PortalId, objRoleInfo.RoleName) == null)
                        {
                            objRoleController.AddRole(objRoleInfo);
                        }
                        else
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("DuplicateRole", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }
                    }
                    else
                    {
                        objRoleController.UpdateRole(objRoleInfo);
                    }
					
                    //Clear Roles Cache
                    DataCache.RemoveCache("GetRoles");

                    Response.Redirect(Globals.NavigateURL());
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
开发者ID:marceltoben,项目名称:evandrix.github.com,代码行数:88,代码来源:EditRoles.ascx.cs

示例5: SaveSettings

        private void SaveSettings()
        {
            var ctlRole = new RoleController();
            RoleInfo role = ctlRole.GetRole(GroupId, PortalId);
            var sec = new PortalSecurity();

            role.RoleName = sec.InputFilter(txtGroupName.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup);

            SaveSetting(ref role, FeatureController.KEY_COUNTRY, cboCountry.SelectedValue);
            SaveSetting(ref role, FeatureController.KEY_COUNTRYFULL, cboCountry.SelectedItem.Text);

            SaveSetting(ref role, FeatureController.KEY_REGION, sec.InputFilter(ParseRegionSaveSetting(), PortalSecurity.FilterFlag.NoMarkup));
            if (role.Settings[FeatureController.KEY_REGION] == cboRegion.SelectedValue)
            {
                SaveSetting(ref role, FeatureController.KEY_REGIONFULL, cboRegion.SelectedItem.Text);
            }
            else
            {
                SaveSetting(ref role, FeatureController.KEY_REGIONFULL, sec.InputFilter(txtRegion.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));
            }

            SaveSetting(ref role, FeatureController.KEY_CITY, sec.InputFilter(txtCity.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_DEFAULTLANGUAGE, cboDefaultLanguage.SelectedValue);

            SaveSetting(ref role, FeatureController.KEY_WEBSITEURL, sec.InputFilter(txtWebsiteUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_FACEBOOKURL, sec.InputFilter(txtFacebookUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_TWITTERURL, sec.InputFilter(txtTwitterUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_LINKEDINURL, sec.InputFilter(txtLinkedInUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_GOOGLEPLUSURL, sec.InputFilter(txtGooglePlusUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_MEETUPURL, sec.InputFilter(txtMeetUpUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_YOUTUBEURL, sec.InputFilter(txtYouTubeUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            // update the role to save the name change
            ctlRole.UpdateRole(role);

            // save the settings
            TestableRoleController.Instance.UpdateRoleSettings(role, true);
        }
开发者ID:RichardHowells,项目名称:dnnextensions,代码行数:45,代码来源:View.ascx.cs

示例6: Save_Click

        private void Save_Click(object sender, EventArgs e)
        {
            if (GroupId > 0)
            {
                RoleController roleController = new RoleController();
                Security.PortalSecurity ps = new Security.PortalSecurity();

                txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting);
                txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
                
                var roleInfo = roleController.GetRole(GroupId, PortalId);
                if (roleInfo != null)
                {

                    if (txtGroupName.Visible) //if this is visible assume that we're editing the groupname
                    {
                        if (txtGroupName.Text != roleInfo.RoleName)
                        {
                            if (roleController.GetRoleByName(PortalId, txtGroupName.Text) != null)
                            {
                                lblInvalidGroupName.Visible = true;
                                return;
                            }
                        }
                    }

                    if(!roleInfo.IsSystemRole)
                    {
                        roleInfo.RoleName = txtGroupName.Text;
                    }
                    
                    roleInfo.Description = txtDescription.Text;
                    roleInfo.IsPublic = rdAccessTypePublic.Checked;

                    if (roleInfo.Settings.ContainsKey("ReviewMembers"))
                        roleInfo.Settings["ReviewMembers"] = chkMemberApproved.Checked.ToString();
                    else
                        roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString());
                    
                    TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true);
                    roleController.UpdateRole(roleInfo);

                    if (inpFile.PostedFile.ContentLength > 0)
                    {
                        IFileManager _fileManager = FileManager.Instance;
                        IFolderManager _folderManager = FolderManager.Instance;
                        var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory);

                        IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                        if (groupFolder == null)
                        {
                            groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                        }
                        if (groupFolder != null)
                        {
                            var fileName = Path.GetFileName(inpFile.PostedFile.FileName);
                            var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true);
                            roleInfo.IconFile = "FileID=" + fileInfo.FileId;
                            roleController.UpdateRole(roleInfo);
                        }
                    }

                    //Clear Roles Cache
                    DataCache.RemoveCache("GetRoles");

                }

                Response.Redirect(Globals.NavigateURL(TabId, "", new String[] { "groupid=" + GroupId.ToString() }));
            }
        }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:72,代码来源:GroupEdit.ascx.cs

示例7: Create_Click

        private void Create_Click(object sender, EventArgs e)
        {
            RoleController roleController = new RoleController();
            Security.PortalSecurity ps = new Security.PortalSecurity();
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting);
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup);

            txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
            txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
            if (roleController.GetRoleByName(PortalId, txtGroupName.Text) != null)
            {
                reqGroupName.Visible = true;
                return;
            }
            List<RoleInfo> modRoles = new List<RoleInfo>();
            foreach (ModulePermissionInfo modulePermissionInfo in ModulePermissionController.GetModulePermissions(ModuleId, TabId))
            {
                if (modulePermissionInfo.PermissionKey == "MODGROUP" && modulePermissionInfo.AllowAccess)
                {
                    modRoles.Add(roleController.GetRole(modulePermissionInfo.RoleID, PortalId));
                }
            }
            RoleInfo roleInfo = new RoleInfo()
            {
                PortalID = PortalId,
                RoleName = txtGroupName.Text,
                Description = txtDescription.Text,
                SecurityMode = SecurityMode.SocialGroup,
                Status = RoleStatus.Approved,
                IsPublic = rdAccessTypePublic.Checked
            };
            var userRoleStatus = RoleStatus.Pending;
            if (GroupModerationEnabled)
            {
                roleInfo.Status = RoleStatus.Pending;
                userRoleStatus = RoleStatus.Pending;
            }
            else
            {
                userRoleStatus = RoleStatus.Approved;
            }

            var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(ModuleId, -1), typeof(ModulePermissionInfo)));
            if (ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP"))
            {
                roleInfo.Status = RoleStatus.Approved;
                userRoleStatus = RoleStatus.Approved;
            }
            roleInfo.RoleGroupID = DefaultRoleGroupId;

            roleInfo.RoleID = roleController.AddRole(roleInfo);
            roleInfo = roleController.GetRole(roleInfo.RoleID, PortalId);
            roleInfo.Settings.Add("URL", Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
            roleInfo.Settings.Add("GroupCreatorName", UserInfo.DisplayName);
            roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString());

            TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true);
            if (inpFile.PostedFile.ContentLength > 0)
            {
                IFileManager _fileManager = FileManager.Instance;
                IFolderManager _folderManager = FolderManager.Instance;
                var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory);

                IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                if (groupFolder == null)
                {
                    groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                }
                if (groupFolder != null)
                {
                    var fileName = Path.GetFileName(inpFile.PostedFile.FileName);
                    var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true);
                    roleInfo.IconFile = "FileID=" + fileInfo.FileId;
                    roleController.UpdateRole(roleInfo);
                }
            }

            Components.Notifications notifications = new Components.Notifications();


            roleController.AddUserRole(PortalId, UserId, roleInfo.RoleID, userRoleStatus, true, Null.NullDate, Null.NullDate);
            if (roleInfo.Status == RoleStatus.Pending)
            {
                //Send notification to Group Moderators to approve/reject group.
                notifications.AddGroupNotification(Constants.GroupPendingNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles);
            }
            else
            {
                //Send notification to Group Moderators informing of new group.
                notifications.AddGroupNotification(Constants.GroupCreatedNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles);

                //Add entry to journal.
                GroupUtilities.CreateJournalEntry(roleInfo, UserInfo);
            }

            Response.Redirect(Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
        }
开发者ID:biganth,项目名称:Curt,代码行数:97,代码来源:Create.ascx.cs

示例8: Save_Click

        private void Save_Click(object sender, EventArgs e)
        {
            if (GroupId > 0)
            {
                RoleController roleController = new RoleController();
                Security.PortalSecurity ps = new Security.PortalSecurity();
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
                var roleInfo = roleController.GetRole(GroupId, PortalId);
                if (roleInfo != null)
                {
                    roleInfo.Description = txtDescription.Text;
                    roleInfo.IsPublic = rdAccessTypePublic.Checked;
                    if (roleInfo.Settings.ContainsKey("URL"))
                    {
                        roleInfo.Settings["URL"] = Globals.NavigateURL(TabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() });
                    } else
                    {
                        roleInfo.Settings.Add("URL", Globals.NavigateURL(TabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
                    }
                    if (roleInfo.Settings.ContainsKey("ReviewMembers"))
                    {
                        roleInfo.Settings["ReviewMembers"] = chkMemberApproved.Checked.ToString();
                    } else
                    {
                        roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString());
                    }
                    TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true);
                    roleController.UpdateRole(roleInfo);

                    if (inpFile.PostedFile.ContentLength > 0)
                    {
                        IFileManager _fileManager = FileManager.Instance;
                        IFolderManager _folderManager = FolderManager.Instance;
                        var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory);

                        IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                        if (groupFolder == null)
                        {
                            groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                        }
                        if (groupFolder != null)
                        {
                            var fileName = Path.GetFileName(inpFile.PostedFile.FileName);
                            var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true);
                            roleInfo.IconFile = "FileID=" + fileInfo.FileId;
                            roleController.UpdateRole(roleInfo);
                        }
                    }

                }
                Response.Redirect(Globals.NavigateURL(TabId, "", new String[] { "groupid=" + GroupId.ToString() }));
            }
        }
开发者ID:biganth,项目名称:Curt,代码行数:54,代码来源:GroupEdit.ascx.cs

示例9: ParseGroupIconFile

        protected string ParseGroupIconFile(object GroupId, object iconFile)
        {
            if (GroupId == null) throw new ArgumentNullException("GroupId cannot be null");

            // return a default icon
            if (iconFile == null) return Page.ResolveClientUrl("/DesktopModules/UGLabsMyGroups/Images/ugdefault.jpg");

            var icon = iconFile.ToString();

            // parse the value to determine if it's a URL or a DNN file
            if (Regex.IsMatch(icon, FeatureController.FILEID_MATCH_PATTERN, RegexOptions.IgnoreCase))
            {
                // the value is FileID=[number]
                var fileIdValue = Regex.Match(icon, FeatureController.FILEID_MATCH_PATTERN, RegexOptions.IgnoreCase).Groups[1].Value;

                if (!Regex.IsMatch(fileIdValue, @"^\d+$")) throw new ArgumentOutOfRangeException("The File ID is not in a valid format.");

                var fileId = int.Parse(fileIdValue);

                var ctlModule = new FeatureController();

                // grab a reference to the image
                var image = FileManager.Instance.GetFile(fileId);

                if (image == null) throw new ArgumentNullException("The image object is null.");

                if (image.Width > 124)
                {
                    // resize and save a new image
                    var thumbnail = CreateGroupIconImage(image);

                    // update the role with the new file id
                    var ctlRole = new RoleController();
                    var role = ctlRole.GetRole(int.Parse(GroupId.ToString()), PortalId);
                    role.IconFile = string.Format("FileID={0}", thumbnail.FileId);
                    ctlRole.UpdateRole(role);

                    return ctlModule.GetImageFileUrl(thumbnail);
                }

                return ctlModule.GetImageFileUrl(image);
            }
            else
            {
                // this is an actual URL
                return icon;
            }
        }
开发者ID:RichardHowells,项目名称:dnnextensions,代码行数:48,代码来源:View.ascx.cs

示例10: JoinGroup

        public ActionResult JoinGroup(int roleId)
        {
            try
            {
                if (UserInfo.UserID >= 0 && roleId > 0)
                {
                    var roleController = new RoleController();
                    roleInfo = roleController.GetRole(roleId, PortalSettings.PortalId);
                    if (roleInfo != null)
                    {
                        var requireApproval = Convert.ToBoolean(roleInfo.Settings["ReviewMembers"].ToString());
                        if (roleInfo.IsPublic && !requireApproval)
                        {
                            roleController.AddUserRole(PortalSettings.PortalId, UserInfo.UserID, roleInfo.RoleID, Null.NullDate);
                            roleController.UpdateRole(roleInfo);
                            return Json(new { Result = "success", URL = roleInfo.Settings["URL"] });
                        }
                        if (roleInfo.IsPublic && requireApproval)
                        {
                            roleController.AddUserRole(PortalSettings.PortalId, UserInfo.UserID, roleInfo.RoleID, RoleStatus.Pending, false, Null.NullDate, Null.NullDate);
                            Components.Notifications notifications = new Components.Notifications();
                            notifications.AddGroupOwnerNotification(Constants.MemberPendingNotification, TabId, ModuleId, roleInfo, UserInfo);
                            return Json(new { Result = "success", URL = string.Empty });
                        }

                        
                    }
                }
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
            }

            return Json(new { Result = "error" });
        }
开发者ID:biganth,项目名称:Curt,代码行数:36,代码来源:GroupServices.cs

示例11: UpgradeToVersion621

        private static void UpgradeToVersion621()
        {
            //update administrators' role description.
            var portalController = new PortalController();
            var roleController = new RoleController();
            var moduleController = new ModuleController();
            foreach (PortalInfo portal in portalController.GetPortals())
            {
                var role = roleController.GetRoleByName(portal.PortalID, "Administrators");
                if(role != null && role.Description == "Portal Administrators")
                {
                    role.Description = "Administrators of this Website";
                    roleController.UpdateRole(role);
                }

                role = roleController.GetRoleByName(portal.PortalID, "Subscribers");
                if (role != null && role.Description == "A public role for portal subscriptions")
                {
                    role.Description = "A public role for site subscriptions";
                    roleController.UpdateRole(role);
                }

                //update about me's template
                var myProfileTabId = TabController.GetTabByTabPath(portal.PortalID, "//ActivityFeed//MyProfile", string.Empty);
                if(myProfileTabId != Null.NullInteger)
                {
                    var tabModules = moduleController.GetTabModules(myProfileTabId);
                    foreach(var module in tabModules.Values)
                    {
                        var settings = moduleController.GetTabModuleSettings(module.TabModuleID);
                        if(settings.ContainsKey("ProfileTemplate") && settings["ProfileTemplate"].ToString().Contains("<div class=\"pBio\">"))
                        {
                            var template = @"<div class=""pBio"">
                                    <h3 data-bind=""text: AboutMeText""></h3>
                                    <span data-bind=""text: EmptyAboutMeText, visible: Biography().length==0""></span>
                                    <p data-bind=""html: Biography""></p>
                                    </div>
                                    <div class=""pAddress"">
                                    <h3 data-bind=""text: LocationText""></h3>
                                    <span data-bind=""text: EmptyLocationText, visible: Street().length=0 && Location().length==0 && Country().length==0 && PostalCode().length==0""></span>
                                    <p><span data-bind=""text: Street()""></span><span data-bind=""visible: Street().length > 0""><br/></span>
                                    <span data-bind=""text: Location()""></span><span data-bind=""visible: Location().length > 0""><br/></span>
                                    <span data-bind=""text: Country()""></span><span data-bind=""visible: Country().length > 0""><br/></span>
                                    <span data-bind=""text: PostalCode()""></span>
                                    </p>
                                    </div>
                                    <div class=""pContact"">
                                    <h3 data-bind=""text: GetInTouchText""></h3>
                                    <span data-bind=""text: EmptyGetInTouchText, visible: Telephone().length==0 && Email().length==0 && Website().length==0 && IM().length==0""></span>
                                    <ul>
                                    <li data-bind=""visible: Telephone().length > 0""><strong><span data-bind=""text: TelephoneText"">:</span></strong> <span data-bind=""text: Telephone()""></span></li>
                                    <li data-bind=""visible: Email().length > 0""><strong><span data-bind=""text: EmailText"">:</span></strong> <span data-bind=""text: Email()""></span></li>
                                    <li data-bind=""visible: Website().length > 0""><strong><span data-bind=""text: WebsiteText"">:</span></strong> <span data-bind=""text: Website()""></span></li>
                                    <li data-bind=""visible: IM().length > 0""><strong><span data-bind=""text: IMText"">:</span></strong> <span data-bind=""text: IM()""></span></li>
                                    </ul>
                                    </div>
                                    <div class=""dnnClear""></div>";
                            moduleController.UpdateTabModuleSetting(module.TabModuleID, "ProfileTemplate", template);
                        }
                    }
                }
            }
        }
开发者ID:biganth,项目名称:Curt,代码行数:63,代码来源:Upgrade.cs


注:本文中的DotNetNuke.Security.Roles.RoleController.UpdateRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。