Ejemplo n.º 1
0
        public override bool IsAuthorized(AuthFilterContext context)
        {
            var menuItem       = GetMenuByIdentifier();
            var portalSettings = PortalSettings.Current;

            if (menuItem == null || portalSettings == null)
            {
                return(false);
            }
            if (!CheckPermissionForAdmin && PortalSecurity.IsInRole(Constants.AdminsRoleName))
            {
                return(true);
            }
            //Permissions seperated by & should be treated with AND operand.
            //Permissions seperated by , are internally treated with OR operand.
            var allPermissionGroups = Permission.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);

            return(allPermissionGroups.All(allPermissions => MenuPermissionController.HasMenuPermission(portalSettings.PortalId, menuItem, allPermissions)));
        }
        public static bool HasTabPermission(string permissionKey)
        {
            var principal = Thread.CurrentPrincipal;

            if (!principal.Identity.IsAuthenticated)
            {
                return(false);
            }

            var currentPortal = PortalController.Instance.GetCurrentPortalSettings();

            bool isAdminUser = currentPortal.UserInfo.IsSuperUser || PortalSecurity.IsInRole(currentPortal.AdministratorRoleName);

            if (isAdminUser)
            {
                return(true);
            }

            return(TabPermissionController.HasTabPermission(permissionKey));
        }
Ejemplo n.º 3
0
        protected void cmdAdd_Click(object sender, EventArgs e)
        {
            try
            {
                // Only Update if the Entered Data is Valid
                if (this.Page.IsValid && !string.IsNullOrEmpty(this.txtCategoryName.Text))
                {
                    var objCategory  = new EventCategoryInfo();
                    var objSecurity  = new PortalSecurity();
                    var categoryName = "";

                    // Filter text for non-admins
                    if (PortalSecurity.IsInRole(this.PortalSettings.AdministratorRoleName))
                    {
                        categoryName = this.txtCategoryName.Text;
                    }
                    else
                    {
                        categoryName =
                            objSecurity.InputFilter(this.txtCategoryName.Text, PortalSecurity.FilterFlag.NoScripting);
                    }

                    //bind text values to object

                    objCategory.Category     = 0;
                    objCategory.PortalID     = this.PortalId;
                    objCategory.CategoryName = categoryName;
                    objCategory.Color        = this.txtCategoryColor.Text;
                    objCategory.FontColor    = this.txtCategoryFontColor.Text;
                    this._objCtlCategory.EventsCategorySave(objCategory);

                    this.SetDefaultValues();
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }

            this.BindData();
        }
Ejemplo n.º 4
0
        private void Page_Load(object sender, EventArgs e)
        {
            this.LocalizeAll();

            if (PortalSecurity.IsInRole(this.PortalSettings.AdministratorRoleName) || this.IsCategoryEditor())
            {
            }
            else
            {
                this.Response.Redirect(this.GetSocialNavigateUrl(), true);
            }

            // Set the selected theme
            this.SetTheme(this.pnlEventsModuleCategories);

            if (!this.Page.IsPostBack)
            {
                this.SetDefaultValues();
                this.BindData();
            }
        }
Ejemplo n.º 5
0
 public ContextSecurity(ModuleInfo objModule)
 {
     user = UserController.Instance.GetCurrentUserInfo();
     if (user.IsSuperUser)
     {
         CanView = CanEdit = IsAdmin = true;
     }
     else
     {
         IsAdmin = PortalSecurity.IsInRole(PortalSettings.Current.AdministratorRoleName);
         if (IsAdmin)
         {
             CanView = CanEdit = true;
         }
         else
         {
             CanView = ModulePermissionController.CanViewModule(objModule);
             CanEdit = ModulePermissionController.HasModulePermission(objModule.ModulePermissions, "EDIT");
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Check if current user can see a specific page
        /// </summary>
        /// <param name="tab"> The TabInfo to be checked</param>
        /// <returns>True if current user can see the specific page. Otherwise, False</returns>
        internal static bool CanSeeVersionedPages(TabInfo tab)
        {
            if (!Thread.CurrentPrincipal.Identity.IsAuthenticated)
            {
                return(false);
            }

            var currentPortalSettings = PortalController.Instance.GetCurrentPortalSettings();

            if (currentPortalSettings == null)
            {
                return(false);
            }
            var isAdminUser = currentPortalSettings.UserInfo.IsSuperUser || PortalSecurity.IsInRole(currentPortalSettings.AdministratorRoleName);

            if (isAdminUser)
            {
                return(true);
            }

            return(TabPermissionController.HasTabPermission(tab.TabPermissions, "EDIT,CONTENT,MANAGE"));
        }
        private bool IsPortalIdValid(int portalId)
        {
            if (UserInfo.IsSuperUser)
            {
                return(true);
            }
            if (PortalSettings.PortalId == portalId)
            {
                return(true);
            }

            var isAdminUser = PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName);

            if (!isAdminUser)
            {
                return(false);
            }

            var mygroup = GetMyPortalGroup();

            return(mygroup != null && mygroup.Any(p => p.PortalID == portalId));
        }
Ejemplo n.º 8
0
        private void Page_Load(object sender, EventArgs e)
        {
            LocalizeAll();

            if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) || IsLocationEditor())
            {
            }
            else
            {
                Response.Redirect(GetSocialNavigateUrl(), true);
            }

            // Set the selected theme
            SetTheme(pnlEventsModuleLocations);

            if (!Page.IsPostBack)
            {
                BindData();
                BindCountry();
                BindRegion();
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdValidate_Click executes when a user selects the Validate link for a username
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdValidate_Click(object sender, EventArgs e)
        {
            if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) == false)
            {
                return;
            }

            if (!String.IsNullOrEmpty(txtUsers.Text))
            {
                //validate username
                UserInfo objUser = UserController.GetUserByName(PortalId, txtUsers.Text);
                if (objUser != null)
                {
                    GetDates(objUser.UserID, RoleId);
                    SelectedUserID = objUser.UserID;
                }
                else
                {
                    txtUsers.Text = "";
                }
            }
            BindGrid();
        }
Ejemplo n.º 10
0
 public ContextSecurity(ModuleInfo objModule)
 {
     user = UserController.Instance.GetCurrentUserInfo();
     if (user.IsSuperUser)
     {
         CanView = CanEdit = CanSubmitSessions = CanAttend = CanManage = IsAdmin = true;
     }
     else
     {
         IsAdmin = PortalSecurity.IsInRole(PortalSettings.Current.AdministratorRoleName);
         if (IsAdmin)
         {
             CanView = CanEdit = CanSubmitSessions = CanAttend = CanManage = true;
         }
         else
         {
             CanView           = ModulePermissionController.CanViewModule(objModule);
             CanEdit           = ModulePermissionController.HasModulePermission(objModule.ModulePermissions, "EDIT");
             CanSubmitSessions = ModulePermissionController.HasModulePermission(objModule.ModulePermissions, "SESSIONSUBMIT");
             CanAttend         = ModulePermissionController.HasModulePermission(objModule.ModulePermissions, "CANATTEND");
             CanManage         = ModulePermissionController.HasModulePermission(objModule.ModulePermissions, "MANAGE");
         }
     }
 }
Ejemplo n.º 11
0
        public static int SaveTabInfoObject(TabInfo tab, TabInfo relativeToTab, TabRelativeLocation location, string templateFileId)
        {
            //Validation:
            //Tab name is required
            //Tab name is invalid
            string invalidType;

            if (!TabController.IsValidTabName(tab.TabName, out invalidType))
            {
                switch (invalidType)
                {
                case "EmptyTabName":
                    throw new DotNetNukeException("Page name is required.", DotNetNukeErrorCode.PageNameRequired);

                case "InvalidTabName":
                    throw new DotNetNukeException("Page name is invalid.", DotNetNukeErrorCode.PageNameInvalid);
                }
            }
            else if ((Validate_IsCircularReference(tab.PortalID, tab.TabID)))
            {
                throw new DotNetNukeException("Cannot move page to that location.", DotNetNukeErrorCode.PageCircularReference);
            }

            bool usingDefaultLanguage = (tab.CultureCode == PortalSettings.Current.DefaultLanguage) || tab.CultureCode == null;

            if (PortalSettings.Current.ContentLocalizationEnabled)
            {
                if ((!usingDefaultLanguage))
                {
                    TabInfo defaultLanguageSelectedTab = tab.DefaultLanguageTab;

                    if ((defaultLanguageSelectedTab == null))
                    {
                        //get the siblings from the selectedtab and iterate through until you find a sibbling with a corresponding defaultlanguagetab
                        //if none are found get a list of all the tabs from the default language and then select the last one
                        var selectedTabSibblings = TabController.Instance.GetTabsByPortal(tab.PortalID).WithCulture(tab.CultureCode, true).AsList();
                        foreach (TabInfo sibling in selectedTabSibblings)
                        {
                            TabInfo siblingDefaultTab = sibling.DefaultLanguageTab;
                            if (((siblingDefaultTab != null)))
                            {
                                defaultLanguageSelectedTab = siblingDefaultTab;
                                break;
                            }
                        }

                        //still haven't found it
                        if ((defaultLanguageSelectedTab == null))
                        {
                            var defaultLanguageTabs = TabController.Instance.GetTabsByPortal(tab.PortalID).WithCulture(PortalSettings.Current.DefaultLanguage, true).AsList();
                            defaultLanguageSelectedTab = defaultLanguageTabs[defaultLanguageTabs.Count];
                            //get the last tab
                        }
                    }

                    relativeToTab = defaultLanguageSelectedTab;
                }
            }


            if ((location != TabRelativeLocation.NOTSET))
            {
                //Check Host tab - don't allow adding before or after
                if ((IsHostConsolePage(relativeToTab) && (location == TabRelativeLocation.AFTER || location == TabRelativeLocation.BEFORE)))
                {
                    throw new DotNetNukeException("You cannot add or move pages before or after the Host tab.", DotNetNukeErrorCode.HostBeforeAfterError);
                }

                TabInfo parentTab      = GetParentTab(relativeToTab, location);
                string  permissionList = "ADD,COPY,EDIT,MANAGE";
                //Check permissions for Page Editors when moving or inserting
                if ((!PortalSecurity.IsInRole("Administrators")))
                {
                    if (((parentTab == null) || !TabPermissionController.HasTabPermission(parentTab.TabPermissions, permissionList)))
                    {
                        throw new DotNetNukeException("You do not have permissions to add or move pages to this location. You can only add or move pages as children of pages you can edit.",
                                                      DotNetNukeErrorCode.PageEditorPermissionError);
                    }
                }

                if (((parentTab != null)))
                {
                    tab.ParentId = parentTab.TabID;
                    tab.Level    = parentTab.Level + 1;
                }
                else
                {
                    tab.ParentId = Null.NullInteger;
                    tab.Level    = 0;
                }
            }

            if ((tab.TabID > Null.NullInteger && tab.TabID == tab.ParentId))
            {
                throw new DotNetNukeException("Parent page is invalid.", DotNetNukeErrorCode.ParentTabInvalid);
            }

            tab.TabPath = Globals.GenerateTabPath(tab.ParentId, tab.TabName);
            //check whether have conflict between tab path and portal alias.
            if (TabController.IsDuplicateWithPortalAlias(PortalSettings.Current.PortalId, tab.TabPath))
            {
                throw new DotNetNukeException("The page path is duplicate with a site alias", DotNetNukeErrorCode.DuplicateWithAlias);
            }

            try
            {
                if ((tab.TabID < 0))
                {
                    if ((tab.TabPermissions.Count == 0 && tab.PortalID != Null.NullInteger))
                    {
                        //Give admin full permission
                        ArrayList permissions = PermissionController.GetPermissionsByTab();

                        foreach (PermissionInfo permission in permissions)
                        {
                            TabPermissionInfo newTabPermission = new TabPermissionInfo();
                            newTabPermission.PermissionID   = permission.PermissionID;
                            newTabPermission.PermissionKey  = permission.PermissionKey;
                            newTabPermission.PermissionName = permission.PermissionName;
                            newTabPermission.AllowAccess    = true;
                            newTabPermission.RoleID         = PortalSettings.Current.AdministratorRoleId;
                            tab.TabPermissions.Add(newTabPermission);
                        }
                    }

                    PortalSettings _PortalSettings = PortalController.Instance.GetCurrentPortalSettings();

                    if (_PortalSettings.ContentLocalizationEnabled)
                    {
                        Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(tab.PortalID);
                        tab.CultureCode = defaultLocale.Code;
                    }
                    else
                    {
                        tab.CultureCode = Null.NullString;
                    }

                    if ((location == TabRelativeLocation.AFTER && (relativeToTab != null)))
                    {
                        tab.TabID = TabController.Instance.AddTabAfter(tab, relativeToTab.TabID);
                    }
                    else if ((location == TabRelativeLocation.BEFORE && (relativeToTab != null)))
                    {
                        tab.TabID = TabController.Instance.AddTabBefore(tab, relativeToTab.TabID);
                    }
                    else
                    {
                        tab.TabID = TabController.Instance.AddTab(tab);
                    }

                    if (_PortalSettings.ContentLocalizationEnabled)
                    {
                        TabController.Instance.CreateLocalizedCopies(tab);
                    }

                    TabController.Instance.UpdateTabSetting(tab.TabID, "CacheProvider", "");
                    TabController.Instance.UpdateTabSetting(tab.TabID, "CacheDuration", "");
                    TabController.Instance.UpdateTabSetting(tab.TabID, "CacheIncludeExclude", "0");
                    TabController.Instance.UpdateTabSetting(tab.TabID, "IncludeVaryBy", "");
                    TabController.Instance.UpdateTabSetting(tab.TabID, "ExcludeVaryBy", "");
                    TabController.Instance.UpdateTabSetting(tab.TabID, "MaxVaryByCount", "");
                }
                else
                {
                    TabController.Instance.UpdateTab(tab);

                    if ((location == TabRelativeLocation.AFTER && (relativeToTab != null)))
                    {
                        TabController.Instance.MoveTabAfter(tab, relativeToTab.TabID);
                    }
                    else if ((location == TabRelativeLocation.BEFORE && (relativeToTab != null)))
                    {
                        TabController.Instance.MoveTabBefore(tab, relativeToTab.TabID);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);

                if (ex.Message.StartsWith("Page Exists"))
                {
                    throw new DotNetNukeException(ex.Message, DotNetNukeErrorCode.PageExists);
                }
            }

            // create the page from a template
            if (!string.IsNullOrEmpty(templateFileId))
            {
                XmlDocument xmlDoc = new XmlDocument {
                    XmlResolver = null
                };
                try
                {
                    var templateFile = FileManager.Instance.GetFile(Convert.ToInt32(templateFileId));
                    xmlDoc.Load(FileManager.Instance.GetFileContent(templateFile));
                    TabController.DeserializePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), tab.PortalID, tab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable());

                    //save tab permissions
                    DeserializeTabPermissions(xmlDoc.SelectNodes("//portal/tabs/tab/tabpermissions/permission"), tab);
                }
                catch (Exception ex)
                {
                    Exceptions.LogException(ex);
                    throw new DotNetNukeException("Unable to process page template.", ex, DotNetNukeErrorCode.DeserializePanesFailed);
                }
            }

            //todo: reload tab from db or send back tabid instead?
            return(tab.TabID);
        }
Ejemplo n.º 12
0
        private bool VerifyUserPermissions()
        {
            if (AddUser && !IsRegister && IsHostMenu && !UserInfo.IsSuperUser)
            {
                AddModuleMessage("NoUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
                DisableForm();
                return(false);
            }

            //Check if User is a member of the Current Portal (or a member of the MasterPortal if PortalGroups enabled)
            if (User.PortalID != Null.NullInteger && User.PortalID != PortalId)
            {
                AddModuleMessage("InvalidUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
                DisableForm();
                return(false);
            }

            //Check if User is a SuperUser and that the current User is a SuperUser
            if (User.IsSuperUser && !UserInfo.IsSuperUser)
            {
                AddModuleMessage("NoUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
                DisableForm();
                return(false);
            }
            if (IsEdit)
            {
                //Check if user has admin rights
                if (!IsAdmin || (User.IsInRole(PortalSettings.AdministratorRoleName) && !PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)))
                {
                    AddModuleMessage("NotAuthorized", ModuleMessage.ModuleMessageType.YellowWarning, true);
                    DisableForm();
                    return(false);
                }
            }
            else
            {
                if (!IsUser)
                {
                    if (Request.IsAuthenticated)
                    {
                        if (!PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                        {
                            //Display current user's profile
                            Response.Redirect(Globals.NavigateURL(PortalSettings.UserTabId, "", "UserID=" + UserInfo.UserID), true);
                        }
                    }
                    else
                    {
                        if ((User.UserID > Null.NullInteger))
                        {
                            AddModuleMessage("NotAuthorized", ModuleMessage.ModuleMessageType.YellowWarning, true);
                            DisableForm();
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 13
0
        public static bool IsAdministrator()
        {
            var administratorRoleName = Globals.GetPortalSettings().AdministratorRoleName;

            return(PortalSecurity.IsInRole(administratorRoleName));
        }
Ejemplo n.º 14
0
        private void SaveLocation(int locationID)
        {
            // Only Update if the Entered Data is Valid
            if (Page.IsValid && !string.IsNullOrEmpty(txtLocationName.Text))
            {
                var    objLocation  = new EventLocationInfo();
                var    objSecurity  = new PortalSecurity();
                var    locationName = "";
                var    mapURL       = "";
                var    street       = "";
                var    postalCode   = "";
                var    city         = "";
                string region       = null;
                string country      = null;

                // Filter text for non-admins
                if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                {
                    locationName = txtLocationName.Text;
                    mapURL       = PutHTTPInFront(txtMapURL.Text);
                    street       = txtStreet.Text;
                    postalCode   = txtPostalCode.Text;
                    city         = txtCity.Text;
                    if (cboRegion.SelectedIndex > 0)
                    {
                        region = cboRegion.SelectedItem.Text;
                    }
                    else
                    {
                        region = txtRegion.Text;
                    }
                    if (cboCountry.SelectedIndex > 0)
                    {
                        country = Convert.ToString(cboCountry.SelectedItem.Text);
                    }
                }
                else
                {
                    locationName =
                        objSecurity.InputFilter(txtLocationName.Text, PortalSecurity.FilterFlag.NoScripting);
                    mapURL = objSecurity.InputFilter(PutHTTPInFront(txtMapURL.Text),
                                                     PortalSecurity.FilterFlag.NoScripting);
                    street     = objSecurity.InputFilter(txtStreet.Text, PortalSecurity.FilterFlag.NoScripting);
                    postalCode =
                        objSecurity.InputFilter(txtPostalCode.Text, PortalSecurity.FilterFlag.NoScripting);
                    city = objSecurity.InputFilter(txtCity.Text, PortalSecurity.FilterFlag.NoScripting);
                    if (cboRegion.SelectedIndex > 0)
                    {
                        region = objSecurity.InputFilter(cboRegion.SelectedItem.Text,
                                                         PortalSecurity.FilterFlag.NoScripting);
                    }
                    else
                    {
                        region = objSecurity.InputFilter(txtRegion.Text, PortalSecurity.FilterFlag.NoScripting);
                    }
                    if (cboCountry.SelectedIndex > 0)
                    {
                        country = objSecurity.InputFilter(Convert.ToString(cboCountry.SelectedItem.Text),
                                                          PortalSecurity.FilterFlag.NoScripting);
                    }
                }

                //bind text values to object
                objLocation.Location     = locationID;
                objLocation.PortalID     = PortalId;
                objLocation.LocationName = locationName;
                objLocation.MapURL       = mapURL;
                objLocation.Street       = street;
                objLocation.PostalCode   = postalCode;
                objLocation.City         = city;
                objLocation.Region       = region;
                objLocation.Country      = country;
                _objCtlLocation.EventsLocationSave(objLocation);

                //Back to normal (add) mode
                txtLocationName.Text = "";
                txtMapURL.Text       = "";
                txtStreet.Text       = "";
                txtPostalCode.Text   = "";
                txtCity.Text         = "";
                txtRegion.Text       = "";
                cboRegion.ClearSelection();
                cboCountry.ClearSelection();

                ViewState.Remove("Location");
                cmdUpdate.Visible = false;
            }
        }
Ejemplo n.º 15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// CreateEditor creates the control collection.
        /// </summary>
        /// -----------------------------------------------------------------------------
        protected override void CreateEditor()
        {
            CategoryDataField             = "PropertyCategory";
            EditorDataField               = "DataType";
            NameDataField                 = "PropertyName";
            RequiredDataField             = "Required";
            ValidationExpressionDataField = "ValidationExpression";
            ValueDataField                = "PropertyValue";
            VisibleDataField              = "Visible";
            VisibilityDataField           = "ProfileVisibility";
            LengthDataField               = "Length";

            base.CreateEditor();

            foreach (FieldEditorControl editor in Fields)
            {
                //Check whether Field is readonly
                string fieldName = editor.Editor.Name;
                ProfilePropertyDefinitionCollection definitions = editor.DataSource as ProfilePropertyDefinitionCollection;
                ProfilePropertyDefinition           definition  = definitions[fieldName];

                if (definition != null && definition.ReadOnly && (editor.Editor.EditMode == PropertyEditorMode.Edit))
                {
                    PortalSettings ps = PortalController.Instance.GetCurrentPortalSettings();
                    if (!PortalSecurity.IsInRole(ps.AdministratorRoleName))
                    {
                        editor.Editor.EditMode = PropertyEditorMode.View;
                    }
                }

                //We need to wire up the RegionControl to the CountryControl
                if (editor.Editor is DNNRegionEditControl)
                {
                    string country = null;

                    foreach (FieldEditorControl checkEditor in Fields)
                    {
                        if (checkEditor.Editor is DNNCountryEditControl)
                        {
                            if (editor.Editor.Category == checkEditor.Editor.Category)
                            {
                                var countryEdit = (DNNCountryEditControl)checkEditor.Editor;
                                country = Convert.ToString(countryEdit.Value);
                            }
                        }
                    }

                    //Create a ListAttribute for the Region
                    string countryKey = "Unknown";
                    int    entryId;
                    if (int.TryParse(country, out entryId))
                    {
                        ListController lc   = new ListController();
                        ListEntryInfo  item = lc.GetListEntryInfo(entryId);
                        if (item != null)
                        {
                            countryKey = item.Value;
                        }
                    }
                    countryKey = "Country." + countryKey;
                    var attributes = new object[1];
                    attributes[0] = new ListAttribute("Region", countryKey, ListBoundField.Id, ListBoundField.Text);
                    editor.Editor.CustomAttributes = attributes;
                }
            }
        }
Ejemplo n.º 16
0
        protected virtual bool HasToolPermissions(string toolName)
        {
            bool isHostTool = false;

            if (this.ToolInfo.ToolName == toolName)
            {
                isHostTool = this.ToolInfo.IsHostTool;
            }
            else if (this.AllTools.ContainsKey(toolName))
            {
                isHostTool = this.AllTools[toolName].IsHostTool;
            }

            if (isHostTool && !UserController.Instance.GetCurrentUserInfo().IsSuperUser)
            {
                return(false);
            }

            bool returnValue = true;

            switch (toolName)
            {
            case "PageSettings":
            case "CopyDesignToChildren":
            case "CopyPermissionsToChildren":
                returnValue = TabPermissionController.CanManagePage();

                if (returnValue && toolName == "CopyPermissionsToChildren")
                {
                    if (!PortalSecurity.IsInRole("Administrators"))
                    {
                        returnValue = false;
                    }
                }

                break;

            case "CopyPage":
                returnValue = TabPermissionController.CanCopyPage();
                break;

            case "DeletePage":
                returnValue = TabPermissionController.CanDeletePage();
                break;

            case "ImportPage":
                returnValue = TabPermissionController.CanImportPage();
                break;

            case "ExportPage":
                returnValue = TabPermissionController.CanExportPage();
                break;

            case "NewPage":
                returnValue = TabPermissionController.CanAddPage();
                break;

            case "Help":
                returnValue = !string.IsNullOrEmpty(Host.HelpURL);
                break;

            default:
                // if it has a module definition, look it up and check permissions
                // if it doesn't exist, assume no permission
                string friendlyName = string.Empty;
                if (this.ToolInfo.ToolName == toolName)
                {
                    friendlyName = this.ToolInfo.ModuleFriendlyName;
                }
                else if (this.AllTools.ContainsKey(toolName))
                {
                    friendlyName = this.AllTools[toolName].ModuleFriendlyName;
                }

                if (!string.IsNullOrEmpty(friendlyName))
                {
                    returnValue = false;
                    ModuleInfo moduleInfo;

                    if (isHostTool)
                    {
                        moduleInfo = GetInstalledModule(Null.NullInteger, friendlyName);
                    }
                    else
                    {
                        moduleInfo = GetInstalledModule(PortalSettings.PortalId, friendlyName);
                    }

                    if (moduleInfo != null)
                    {
                        returnValue = ModulePermissionController.CanViewModule(moduleInfo);
                    }
                }

                break;
            }

            return(returnValue);
        }
Ejemplo n.º 17
0
        protected void OnRolesGridItemDataBound(object sender, GridItemEventArgs e)
        {
            var item = e.Item;

            switch (item.ItemType)
            {
            case GridItemType.SelectedItem:
            case GridItemType.AlternatingItem:
            case GridItemType.Item:
            {
                var gridDataItem = (GridDataItem)item;

                var editLink = gridDataItem["EditButton"].Controls[0] as HyperLink;
                if (editLink != null)
                {
                    var role = (RoleInfo)item.DataItem;
                    editLink.Visible = role.RoleName != PortalSettings.AdministratorRoleName || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName));
                }

                var rolesLink = gridDataItem["RolesButton"].Controls[0] as HyperLink;
                if (rolesLink != null)
                {
                    var role = (RoleInfo)item.DataItem;
                    rolesLink.Visible = (role.Status == RoleStatus.Approved) && (role.RoleName != PortalSettings.AdministratorRoleName || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)));
                }
            }
            break;
            }
        }
Ejemplo n.º 18
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// grdUsers_ItemDataBound runs when a row in the grid is bound
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	01/05/2007	Intial documentation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void grdUsers_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            var item = e.Item;

            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.SelectedItem)
            {
                var imgApprovedDeleted    = item.FindControl("imgApprovedDeleted");
                var imgNotApprovedDeleted = item.FindControl("imgNotApprovedDeleted");
                var imgApproved           = item.FindControl("imgApproved");
                var imgNotApproved        = item.FindControl("imgNotApproved");

                var user = (UserInfo)item.DataItem;
                if (user != null)
                {
                    if (user.IsDeleted)
                    {
                        foreach (WebControl control in item.Controls)
                        {
                            control.Attributes.Remove("class");
                            control.Attributes.Add("class", "NormalDeleted");
                        }
                        if (imgApprovedDeleted != null && user.Membership.Approved)
                        {
                            imgApprovedDeleted.Visible = true;
                        }
                        else if (imgNotApprovedDeleted != null && !user.Membership.Approved)
                        {
                            imgNotApprovedDeleted.Visible = true;
                        }
                    }
                    else
                    {
                        if (imgApproved != null && user.Membership.Approved)
                        {
                            imgApproved.Visible = true;
                        }
                        else if (imgNotApproved != null && !user.Membership.Approved)
                        {
                            imgNotApproved.Visible = true;
                        }
                    }
                }

                var imgColumnControl = item.Controls[0].Controls[0];
                if (imgColumnControl is HyperLink)
                {
                    var editLink = (HyperLink)imgColumnControl;

                    editLink.Visible = (!user.IsInRole(PortalSettings.AdministratorRoleName) || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)));
                    if (editLink.Visible)
                    {
                        if (user.IsSuperUser)
                        {
                            editLink.Visible = PortalSettings.UserInfo.IsSuperUser;
                        }
                    }
                }

                imgColumnControl = item.Controls[1].Controls[0];
                if (imgColumnControl is ImageButton)
                {
                    var delImage = (ImageButton)imgColumnControl;
                    delImage.Visible = IsCommandAllowed(user, "Delete");
                }


                imgColumnControl = item.Controls[2].Controls[0];
                if (imgColumnControl is HyperLink)
                {
                    var rolesLink = (HyperLink)imgColumnControl;

                    rolesLink.Visible = !user.IsSuperUser && (!user.IsInRole(PortalSettings.AdministratorRoleName) ||
                                                              (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)));
                }

                imgColumnControl = item.Controls[3].FindControl("imgOnline");
                if (imgColumnControl is Image)
                {
                    var userOnlineImage = (System.Web.UI.WebControls.Image)imgColumnControl;
                    userOnlineImage.Visible = user.Membership.IsOnLine;
                }

                imgColumnControl = item.Controls[3].Controls[0];
                if (imgColumnControl is ImageButton)
                {
                    var restoreImage = (ImageButton)imgColumnControl;
                    restoreImage.Visible = IsCommandAllowed(user, "Restore");
                }

                imgColumnControl = item.Controls[4].Controls[0];
                if (imgColumnControl is ImageButton)
                {
                    ImageButton removeImage = (ImageButton)imgColumnControl;
                    removeImage.Visible = IsCommandAllowed(user, "Remove");
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Page_Load runs when the control is loaded.
        /// </summary>
        /// <history>
        ///     [cnurse]	10/06/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    // localization
                    lblPageFunctions.Text = Localization.GetString("PageFunctions", this.LocalResourceFile);
                    optModuleType.Items.FindByValue("0").Selected = true;
                    lblCommonTasks.Text         = Localization.GetString("CommonTasks", this.LocalResourceFile);
                    imgAddTabIcon.AlternateText = Localization.GetString("AddTab.AlternateText", this.LocalResourceFile);
                    cmdAddTab.Text = Localization.GetString("AddTab", this.LocalResourceFile);
                    imgEditTabIcon.AlternateText = Localization.GetString("EditTab.AlternateText", this.LocalResourceFile);
                    cmdEditTab.Text = Localization.GetString("EditTab", this.LocalResourceFile);
                    imgDeleteTabIcon.AlternateText = Localization.GetString("DeleteTab.AlternateText", this.LocalResourceFile);
                    cmdDeleteTab.Text            = Localization.GetString("DeleteTab", this.LocalResourceFile);
                    imgCopyTabIcon.AlternateText = Localization.GetString("CopyTab.AlternateText", this.LocalResourceFile);
                    cmdCopyTab.Text = Localization.GetString("CopyTab", this.LocalResourceFile);
                    imgPreviewTabIcon.AlternateText = Localization.GetString("PreviewTab.AlternateText", this.LocalResourceFile);
                    cmdPreviewTab.Text = Localization.GetString("PreviewTab", this.LocalResourceFile);
                    if (IsPreview)
                    {
                        imgPreviewTabIcon.ImageUrl = "~/Admin/ControlPanel/images/iconbar_unpreviewtab.gif";
                    }
                    lblModule.Text = Localization.GetString("Module", this.LocalResourceFile);
                    lblPane.Text   = Localization.GetString("Pane", this.LocalResourceFile);
                    lblTitle.Text  = Localization.GetString("Title", this.LocalResourceFile);
                    lblAlign.Text  = Localization.GetString("Align", this.LocalResourceFile);
                    imgAddModuleIcon.AlternateText = Localization.GetString("AddModule.AlternateText", this.LocalResourceFile);
                    cmdAddModule.Text          = Localization.GetString("AddModule", this.LocalResourceFile);
                    cmdInstallFeatures.Text    = Localization.GetString("InstallFeatures", this.LocalResourceFile);
                    imgRolesIcon.AlternateText = Localization.GetString("Roles.AlternateText", this.LocalResourceFile);
                    cmdRoles.Text             = Localization.GetString("Roles", this.LocalResourceFile);
                    imgSiteIcon.AlternateText = Localization.GetString("Site.AlternateText", this.LocalResourceFile);
                    cmdSite.Text = Localization.GetString("Site", this.LocalResourceFile);
                    imgUsersIcon.AlternateText = Localization.GetString("Users.AlternateText", this.LocalResourceFile);
                    cmdUsers.Text = Localization.GetString("Users", this.LocalResourceFile);
                    imgFilesIcon.AlternateText = Localization.GetString("Files.AlternateText", this.LocalResourceFile);
                    cmdFiles.Text = Localization.GetString("Files", this.LocalResourceFile);
                    imgSearchIndexIcon.AlternateText = Localization.GetString("SearchIndex.AlternateText", this.LocalResourceFile);
                    cmdSearchIndex.Text = Localization.GetString("SearchIndex", this.LocalResourceFile);

                    if (PortalSettings.ActiveTab.IsAdminTab)
                    {
                        imgEditTabIcon.ImageUrl   = "~/Admin/ControlPanel/images/iconbar_edittab_bw.gif";
                        cmdEditTab.Enabled        = false;
                        cmdEditTabIcon.Enabled    = false;
                        imgDeleteTabIcon.ImageUrl = "~/Admin/ControlPanel/images/iconbar_deletetab_bw.gif";
                        cmdDeleteTab.Enabled      = false;
                        cmdDeleteTabIcon.Enabled  = false;
                        imgCopyTabIcon.ImageUrl   = "~/Admin/ControlPanel/images/iconbar_copytab_bw.gif";
                        cmdCopyTab.Enabled        = false;
                        cmdCopyTabIcon.Enabled    = false;
                    }
                    else
                    {
                        ClientAPI.AddButtonConfirm(cmdDeleteTab, Localization.GetString("DeleteTabConfirm", this.LocalResourceFile));
                        ClientAPI.AddButtonConfirm(cmdDeleteTabIcon, Localization.GetString("DeleteTabConfirm", this.LocalResourceFile));
                    }

                    if (Globals.IsAdminControl())
                    {
                        cmdAddModule.Enabled      = false;
                        imgAddModuleIcon.ImageUrl = "~/Admin/ControlPanel/images/iconbar_addmodule_bw.gif";
                        cmdAddModuleIcon.Enabled  = false;
                    }

                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) == false)
                    {
                        imgSiteIcon.ImageUrl  = "~/Admin/ControlPanel/images/iconbar_site_bw.gif";
                        cmdSite.Enabled       = false;
                        cmdSiteIcon.Enabled   = false;
                        imgUsersIcon.ImageUrl = "~/Admin/ControlPanel/images/iconbar_users_bw.gif";
                        cmdUsers.Enabled      = false;
                        cmdUsersIcon.Enabled  = false;
                        imgRolesIcon.ImageUrl = "~/Admin/ControlPanel/images/iconbar_roles_bw.gif";
                        cmdRoles.Enabled      = false;
                        cmdRolesIcon.Enabled  = false;
                        imgFilesIcon.ImageUrl = "~/Admin/ControlPanel/images/iconbar_files_bw.gif";
                        cmdFiles.Enabled      = false;
                        cmdFilesIcon.Enabled  = false;
                    }

                    UserInfo objUser = UserController.GetCurrentUserInfo();
                    if (objUser != null)
                    {
                        if (!objUser.IsSuperUser)
                        {
                            rowInstallModule.Visible = false;
                        }
                    }

                    BindData();

                    if (PortalSettings.ActiveTab.IsAdminTab == false & Globals.IsAdminControl() == false)
                    {
                        for (int intItem = 0; intItem < PortalSettings.ActiveTab.Panes.Count; intItem++)
                        {
                            cboPanes.Items.Add(Convert.ToString(PortalSettings.ActiveTab.Panes[intItem]));
                        }
                    }
                    else
                    {
                        cboPanes.Items.Add(Globals.glbDefaultPane);
                    }
                    if (cboPanes.Items.FindByValue(Globals.glbDefaultPane) != null)
                    {
                        cboPanes.Items.FindByValue(Globals.glbDefaultPane).Selected = true;
                    }

                    if (cboPermission.Items.Count > 0)
                    {
                        cboPermission.SelectedIndex = 0; // view
                    }

                    if (cboAlign.Items.Count > 0)
                    {
                        cboAlign.SelectedIndex = 0; // left
                    }

                    if (cboPosition.Items.Count > 0)
                    {
                        cboPosition.SelectedIndex = 1; // bottom
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 20
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// grdRoles_ItemDataBound runs when a row in the grid is bound
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	11/28/2008 Created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnRolesGridItemDataBound(object sender, DataGridItemEventArgs e)
        {
            var item = e.Item;

            switch (item.ItemType)
            {
            case ListItemType.SelectedItem:
            case ListItemType.AlternatingItem:
            case ListItemType.Item:
            {
                var imgColumnControl = item.Controls[0].Controls[0];
                if (imgColumnControl is HyperLink)
                {
                    var editLink = (HyperLink)imgColumnControl;
                    var role     = (RoleInfo)item.DataItem;
                    editLink.Visible = role.RoleName != PortalSettings.AdministratorRoleName || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName));
                }
                imgColumnControl = item.Controls[1].Controls[0];
                if (imgColumnControl is HyperLink)
                {
                    var rolesLink = (HyperLink)imgColumnControl;
                    var role      = (RoleInfo)item.DataItem;
                    rolesLink.Visible = (role.Status == RoleStatus.Approved) && (role.RoleName != PortalSettings.AdministratorRoleName || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)));
                }
            }
            break;
            }
        }
Ejemplo n.º 21
0
        private bool VerifyUserPermissions()
        {
            if (this.AddUser && this.IsHostMenu && !this.UserInfo.IsSuperUser)
            {
                this.AddModuleMessage("NoUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
                this.DisableForm();
                return(false);
            }

            // Check if User is a member of the Current Portal (or a member of the MasterPortal if PortalGroups enabled)
            if (this.User.PortalID != Null.NullInteger && this.User.PortalID != this.PortalId)
            {
                this.AddModuleMessage("InvalidUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
                this.DisableForm();
                return(false);
            }

            // Check if User is a SuperUser and that the current User is a SuperUser
            if (this.User.IsSuperUser && !this.UserInfo.IsSuperUser)
            {
                this.AddModuleMessage("NoUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
                this.DisableForm();
                return(false);
            }

            if (this.IsEdit)
            {
                // Check if user has admin rights
                if (!this.IsAdmin || (this.User.IsInRole(this.PortalSettings.AdministratorRoleName) && !PortalSecurity.IsInRole(this.PortalSettings.AdministratorRoleName)))
                {
                    this.AddModuleMessage("NotAuthorized", ModuleMessage.ModuleMessageType.YellowWarning, true);
                    this.DisableForm();
                    return(false);
                }
            }
            else
            {
                if (this.Request.IsAuthenticated)
                {
                    if (!PortalSecurity.IsInRole(this.PortalSettings.AdministratorRoleName))
                    {
                        if (this.HasManageUsersModulePermission() == false)
                        {
                            // Display current user's profile
                            this.Response.Redirect(this._navigationManager.NavigateURL(this.PortalSettings.UserTabId, string.Empty, "UserID=" + this.UserInfo.UserID), true);
                        }
                    }
                }
                else
                {
                    if (this.User.UserID > Null.NullInteger)
                    {
                        this.AddModuleMessage("NotAuthorized", ModuleMessage.ModuleMessageType.YellowWarning, true);
                        this.DisableForm();
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 22
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ddlMode.SelectedIndexChanged      += ddlMode_SelectedIndexChanged;
            ddlUICulture.SelectedIndexChanged += ddlUICulture_SelectedIndexChanged;

            try
            {
                AdminPanel.Visible         = false;
                AdvancedToolsPanel.Visible = false;

                if (ControlPanel.Visible)
                {
                    ClientResourceManager.RegisterStyleSheet(this.Page, "~/admin/ControlPanel/module.css");
                    jQuery.RequestHoverIntentRegistration();
                    ClientResourceManager.RegisterScript(this.Page, "~/Resources/ControlPanel/ControlPanel.debug.js");
                }

                jQuery.RequestDnnPluginsRegistration();

                Control copyPageButton = CurrentPagePanel.FindControl("CopyPage");
                if ((copyPageButton != null))
                {
                    copyPageButton.Visible = LocaleController.Instance.IsDefaultLanguage(LocaleController.Instance.GetCurrentLocale(PortalSettings.PortalId).Code);
                }


                if ((Request.IsAuthenticated))
                {
                    UserInfo user = UserController.GetCurrentUserInfo();
                    if (((user != null)))
                    {
                        bool isAdmin = user.IsInRole(PortalSettings.Current.AdministratorRoleName);
                        AdminPanel.Visible = isAdmin;
                    }
                }

                if (IsPageAdmin())
                {
                    ControlPanel.Visible = true;
                    BodyPanel.Visible    = true;

                    if ((DotNetNukeContext.Current.Application.Name == "DNNCORP.CE"))
                    {
                        //Hide Support icon in CE
                        AdminPanel.FindControl("SupportTickets").Visible = false;
                    }
                    else
                    {
                        //Show PE/XE tools
                        AdvancedToolsPanel.Visible = true;
                    }

                    Localize();

                    if (!Page.IsPostBack)
                    {
                        UserInfo objUser = UserController.GetCurrentUserInfo();
                        if ((objUser != null))
                        {
                            if (objUser.IsSuperUser)
                            {
                                hypMessage.ImageUrl = Upgrade.UpgradeIndicator(DotNetNukeContext.Current.Application.Version, Request.IsLocal, Request.IsSecureConnection);
                                if (!string.IsNullOrEmpty(hypMessage.ImageUrl))
                                {
                                    hypMessage.ToolTip     = Localization.GetString("hypUpgrade.Text", LocalResourceFile);
                                    hypMessage.NavigateUrl = Upgrade.UpgradeRedirect();
                                }
                            }
                            else
                            {
                                if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) && Host.DisplayCopyright)
                                {
                                    hypMessage.ImageUrl    = "~/images/branding/iconbar_logo.png";
                                    hypMessage.ToolTip     = DotNetNukeContext.Current.Application.Description;
                                    hypMessage.NavigateUrl = Localization.GetString("hypMessageUrl.Text", LocalResourceFile);
                                }
                                else
                                {
                                    hypMessage.Visible = false;
                                }

                                if (!TabPermissionController.CanAddContentToPage())
                                {
                                    CommonTasksPanel.Visible = false;
                                }
                            }
                            if (PortalSettings.AllowUserUICulture)
                            {
                                object oCulture = DotNetNuke.Services.Personalization.Personalization.GetProfile("Usability", "UICulture");
                                string currentCulture;
                                if (oCulture != null)
                                {
                                    currentCulture = oCulture.ToString();
                                }
                                else
                                {
                                    Localization l = new Localization();
                                    currentCulture = l.CurrentUICulture;
                                }
                                Localization.LoadCultureDropDownList(ddlUICulture, CultureDropDownTypes.NativeName, currentCulture);
                                //only show language selector if more than one language
                                if (ddlUICulture.Items.Count > 1)
                                {
                                    lblUILanguage.Visible = true;
                                    ddlUICulture.Visible  = true;

                                    if (oCulture == null)
                                    {
                                        SetLanguage(true);
                                    }
                                }
                            }
                        }
                        SetMode(false);
                    }
                }
                else if (IsModuleAdmin())
                {
                    ControlPanel.Visible = true;
                    BodyPanel.Visible    = false;
                    adminMenus.Visible   = false;
                    if (!Page.IsPostBack)
                    {
                        SetMode(false);
                    }
                }
                else
                {
                    ControlPanel.Visible = false;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 23
0
        private void GrdUsersOnItemDataBound(object sender, GridItemEventArgs e)
        {
            var item = e.Item;

            if (item.ItemType == GridItemType.Item || item.ItemType == GridItemType.AlternatingItem || item.ItemType == GridItemType.SelectedItem)
            {
                var imgApprovedDeleted    = item.FindControl("imgApprovedDeleted");
                var imgNotApprovedDeleted = item.FindControl("imgNotApprovedDeleted");
                var imgApproved           = item.FindControl("imgApproved");
                var imgNotApproved        = item.FindControl("imgNotApproved");

                var user = (UserInfo)item.DataItem;

                if (user == null)
                {
                    return;
                }

                if (user.IsDeleted)
                {
                    foreach (WebControl control in item.Controls)
                    {
                        control.Attributes.Remove("class");
                        control.Attributes.Add("class", "NormalDeleted");
                    }
                    if (imgApprovedDeleted != null && user.Membership.Approved)
                    {
                        imgApprovedDeleted.Visible = true;
                    }
                    else if (imgNotApprovedDeleted != null && !user.Membership.Approved)
                    {
                        imgNotApprovedDeleted.Visible = true;
                    }
                }
                else
                {
                    if (imgApproved != null && user.Membership.Approved)
                    {
                        imgApproved.Visible = true;
                    }
                    else if (imgNotApproved != null && !user.Membership.Approved)
                    {
                        imgNotApproved.Visible = true;
                    }
                }

                var gridDataItem = (GridDataItem)item;

                var editLink = gridDataItem["EditButton"].Controls[0] as HyperLink;
                if (editLink != null)
                {
                    editLink.Visible = (!user.IsInRole(PortalSettings.AdministratorRoleName) || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)));
                    if (editLink.Visible)
                    {
                        if (user.IsSuperUser)
                        {
                            editLink.Visible = PortalSettings.UserInfo.IsSuperUser;
                        }
                    }
                }

                var delete = (DnnImageButton)item.FindControl("Delete");
                delete.Visible         = IsCommandAllowed(user, "Delete");
                delete.CommandArgument = user.UserID.ToString(CultureInfo.InvariantCulture);
                delete.ToolTip         = Localization.GetString("Delete.Text", LocalResourceFile);

                var restore = (DnnImageButton)item.FindControl("Restore");
                restore.Visible         = IsCommandAllowed(user, "Restore");
                restore.CommandArgument = user.UserID.ToString(CultureInfo.InvariantCulture);
                restore.ToolTip         = Localization.GetString("Restore.Text", LocalResourceFile);

                var remove = (DnnImageButton)item.FindControl("Remove");
                remove.Visible         = IsCommandAllowed(user, "Remove");
                remove.CommandArgument = user.UserID.ToString(CultureInfo.InvariantCulture);
                remove.ToolTip         = Localization.GetString("Remove.Text", LocalResourceFile);

                var rolesColumn = gridDataItem["RolesButton"].Controls[0];
                rolesColumn.Visible = !user.IsSuperUser && (!user.IsInRole(PortalSettings.AdministratorRoleName) ||
                                                            (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)));

                var onlineControl = (DnnImage)item.FindControl("imgOnline");
                if (onlineControl != null)
                {
                    onlineControl.Visible = user.Membership.IsOnLine;
                    onlineControl.ToolTip = Localization.GetString("Online.Text", LocalResourceFile);
                }
            }
        }
Ejemplo n.º 24
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.ddlMode.SelectedIndexChanged      += this.ddlMode_SelectedIndexChanged;
            this.ddlUICulture.SelectedIndexChanged += this.ddlUICulture_SelectedIndexChanged;

            try
            {
                this.AdminPanel.Visible         = false;
                this.AdvancedToolsPanel.Visible = false;

                if (this.ControlPanel.Visible && this.IncludeInControlHierarchy)
                {
                    ClientResourceManager.RegisterStyleSheet(this.Page, "~/admin/ControlPanel/module.css");
                    ClientResourceManager.RegisterScript(this.Page, "~/Resources/ControlPanel/ControlPanel.debug.js");
                }

                JavaScript.RequestRegistration(CommonJs.DnnPlugins);

                Control copyPageButton = this.CurrentPagePanel.FindControl("CopyPage");
                if (copyPageButton != null)
                {
                    copyPageButton.Visible = LocaleController.Instance.IsDefaultLanguage(LocaleController.Instance.GetCurrentLocale(this.PortalSettings.PortalId).Code);
                }

                if (this.Request.IsAuthenticated)
                {
                    UserInfo user = UserController.Instance.GetCurrentUserInfo();
                    if (user != null)
                    {
                        bool isAdmin = user.IsInRole(PortalSettings.Current.AdministratorRoleName);
                        this.AdminPanel.Visible = isAdmin;
                    }
                }

                if (this.IsPageAdmin())
                {
                    this.ControlPanel.Visible = true;
                    this.BodyPanel.Visible    = true;

                    if (DotNetNukeContext.Current.Application.Name == "DNNCORP.CE")
                    {
                        // Hide Support icon in CE
                        this.AdminPanel.FindControl("SupportTickets").Visible = false;
                    }
                    else
                    {
                        // Show PE/XE tools
                        this.AdvancedToolsPanel.Visible = true;
                    }

                    this.Localize();

                    if (!this.Page.IsPostBack)
                    {
                        UserInfo objUser = UserController.Instance.GetCurrentUserInfo();
                        if (objUser != null)
                        {
                            if (objUser.IsSuperUser)
                            {
                                this.hypMessage.ImageUrl = Upgrade.UpgradeIndicator(DotNetNukeContext.Current.Application.Version, this.Request.IsLocal, this.Request.IsSecureConnection);
                                if (!string.IsNullOrEmpty(this.hypMessage.ImageUrl))
                                {
                                    this.hypMessage.ToolTip     = Localization.GetString("hypUpgrade.Text", this.LocalResourceFile);
                                    this.hypMessage.NavigateUrl = Upgrade.UpgradeRedirect();
                                }
                            }
                            else
                            {
                                if (PortalSecurity.IsInRole(this.PortalSettings.AdministratorRoleName) && Host.DisplayCopyright)
                                {
                                    this.hypMessage.ImageUrl    = "~/images/branding/iconbar_logo.png";
                                    this.hypMessage.ToolTip     = DotNetNukeContext.Current.Application.Description;
                                    this.hypMessage.NavigateUrl = Localization.GetString("hypMessageUrl.Text", this.LocalResourceFile);
                                }
                                else
                                {
                                    this.hypMessage.Visible = false;
                                }

                                if (!TabPermissionController.CanAddContentToPage())
                                {
                                    this.CommonTasksPanel.Visible = false;
                                }
                            }

                            if (this.PortalSettings.AllowUserUICulture)
                            {
                                object oCulture = DotNetNuke.Services.Personalization.Personalization.GetProfile("Usability", "UICulture");
                                string currentCulture;
                                if (oCulture != null)
                                {
                                    currentCulture = oCulture.ToString();
                                }
                                else
                                {
                                    Localization l = new Localization();
                                    currentCulture = l.CurrentUICulture;
                                }

                                // Localization.LoadCultureDropDownList(ddlUICulture, CultureDropDownTypes.NativeName, currentCulture);
                                IEnumerable <ListItem> cultureListItems = Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, currentCulture, string.Empty, false);
                                foreach (var cultureItem in cultureListItems)
                                {
                                    this.ddlUICulture.AddItem(cultureItem.Text, cultureItem.Value);
                                }

                                var selectedCultureItem = this.ddlUICulture.FindItemByValue(currentCulture);
                                if (selectedCultureItem != null)
                                {
                                    selectedCultureItem.Selected = true;
                                }

                                // only show language selector if more than one language
                                if (this.ddlUICulture.Items.Count > 1)
                                {
                                    this.lblUILanguage.Visible = true;
                                    this.ddlUICulture.Visible  = true;

                                    if (oCulture == null)
                                    {
                                        this.SetLanguage(true);
                                    }
                                }
                            }
                        }

                        this.SetMode(false);
                    }
                }
                else if (this.IsModuleAdmin())
                {
                    this.ControlPanel.Visible = true;
                    this.BodyPanel.Visible    = false;
                    this.adminMenus.Visible   = false;
                    if (!this.Page.IsPostBack)
                    {
                        this.SetMode(false);
                    }
                }
                else
                {
                    this.ControlPanel.Visible = false;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 25
0
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    var allTabsChanged = false;
                    //TODO: REMOVE IF UNUSED
                    //var allowIndexChanged = false;

                    //only Portal Administrators can manage the visibility on all Tabs
                    var isAdmin = PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName);
                    chkAllModules.Enabled = isAdmin;

                    //tab administrators can only manage their own tab
                    if (!TabPermissionController.CanAdminPage())
                    {
                        chkAllTabs.Enabled    = false;
                        chkNewTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllowIndex.Enabled = false;
                        cboTab.Enabled        = false;
                    }
                    Module.ModuleID    = _moduleId;
                    Module.ModuleTitle = txtTitle.Text;
                    Module.Alignment   = cboAlign.SelectedItem.Value;
                    Module.Color       = txtColor.Text;
                    Module.Border      = txtBorder.Text;
                    Module.IconFile    = ctlIcon.Url;
                    Module.CacheTime   = !String.IsNullOrEmpty(txtCacheDuration.Text)
                                            ? Int32.Parse(txtCacheDuration.Text)
                                            : 0;
                    Module.CacheMethod = cboCacheProvider.SelectedValue;
                    Module.TabID       = TabId;
                    if (Module.AllTabs != chkAllTabs.Checked)
                    {
                        allTabsChanged = true;
                    }
                    Module.AllTabs = chkAllTabs.Checked;

                    // collect these first as any settings update will clear the cache
                    var originalChecked = Settings["hideadminborder"] != null && bool.Parse(Settings["hideadminborder"].ToString());
                    var allowIndex      = Settings.ContainsKey("AllowIndex") && Convert.ToBoolean(Settings["AllowIndex"]);
                    var oldMoniker      = ((string)Settings["Moniker"] ?? "").TrimToLength(100);
                    var newMoniker      = txtMoniker.Text.TrimToLength(100);
                    if (!oldMoniker.Equals(txtMoniker.Text))
                    {
                        var ids = TabModulesController.Instance.GetTabModuleIdsBySetting("Moniker", newMoniker);
                        if (ids != null && ids.Count > 0)
                        {
                            //Warn user - duplicate moniker value
                            Skin.AddModuleMessage(this, Localization.GetString("MonikerExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }
                        ModuleController.Instance.UpdateTabModuleSetting(Module.TabModuleID, "Moniker", newMoniker);
                    }

                    if (originalChecked != chkAdminBorder.Checked)
                    {
                        ModuleController.Instance.UpdateTabModuleSetting(Module.TabModuleID, "hideadminborder", chkAdminBorder.Checked.ToString());
                    }

                    //check whether allow index value is changed
                    if (allowIndex != chkAllowIndex.Checked)
                    {
                        ModuleController.Instance.UpdateTabModuleSetting(Module.TabModuleID, "AllowIndex", chkAllowIndex.Checked.ToString());
                    }

                    switch (Int32.Parse(cboVisibility.SelectedItem.Value))
                    {
                    case 0:
                        Module.Visibility = VisibilityState.Maximized;
                        break;

                    case 1:
                        Module.Visibility = VisibilityState.Minimized;
                        break;

                    //case 2:
                    default:
                        Module.Visibility = VisibilityState.None;
                        break;
                    }

                    Module.IsDeleted = false;
                    Module.Header    = txtHeader.Text;
                    Module.Footer    = txtFooter.Text;

                    Module.StartDate = startDatePicker.SelectedDate != null
                                        ? startDatePicker.SelectedDate.Value
                                        : Null.NullDate;

                    Module.EndDate = endDatePicker.SelectedDate != null
                                        ? endDatePicker.SelectedDate.Value
                                        : Null.NullDate;

                    Module.ContainerSrc = moduleContainerCombo.SelectedValue;
                    Module.ModulePermissions.Clear();
                    Module.ModulePermissions.AddRange(dgPermissions.Permissions);
                    Module.Terms.Clear();
                    Module.Terms.AddRange(termsSelector.Terms);

                    if (!Module.IsShared)
                    {
                        Module.InheritViewPermissions = chkInheritPermissions.Checked;
                        Module.IsShareable            = isShareableCheckBox.Checked;
                        Module.IsShareableViewOnly    = isShareableViewOnlyCheckBox.Checked;
                    }

                    Module.DisplayTitle     = chkDisplayTitle.Checked;
                    Module.DisplayPrint     = chkDisplayPrint.Checked;
                    Module.DisplaySyndicate = chkDisplaySyndicate.Checked;
                    Module.IsWebSlice       = chkWebSlice.Checked;
                    Module.WebSliceTitle    = txtWebSliceTitle.Text;

                    Module.WebSliceExpiryDate = diWebSliceExpiry.SelectedDate != null
                                                ? diWebSliceExpiry.SelectedDate.Value
                                                : Null.NullDate;

                    if (!string.IsNullOrEmpty(txtWebSliceTTL.Text))
                    {
                        Module.WebSliceTTL = Convert.ToInt32(txtWebSliceTTL.Text);
                    }
                    Module.IsDefaultModule = chkDefault.Checked;
                    Module.AllModules      = chkAllModules.Checked;
                    ModuleController.Instance.UpdateModule(Module);

                    //Update Custom Settings
                    if (SettingsControl != null)
                    {
                        try
                        {
                            SettingsControl.UpdateSettings();
                        }
                        catch (ThreadAbortException exc)
                        {
                            Logger.Debug(exc);

                            Thread.ResetAbort(); //necessary
                        }
                        catch (Exception ex)
                        {
                            Exceptions.LogException(ex);
                        }
                    }

                    //These Module Copy/Move statements must be
                    //at the end of the Update as the Controller code assumes all the
                    //Updates to the Module have been carried out.

                    //Check if the Module is to be Moved to a new Tab
                    if (!chkAllTabs.Checked)
                    {
                        var newTabId = Int32.Parse(cboTab.SelectedValue);
                        if (TabId != newTabId)
                        {
                            //First check if there already is an instance of the module on the target page
                            var tmpModule = ModuleController.Instance.GetModule(_moduleId, newTabId, false);
                            if (tmpModule == null)
                            {
                                //Move module
                                ModuleController.Instance.MoveModule(_moduleId, TabId, newTabId, Globals.glbDefaultPane);
                            }
                            else
                            {
                                //Warn user
                                Skin.AddModuleMessage(this, Localization.GetString("ModuleExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                                return;
                            }
                        }
                    }

                    //Check if Module is to be Added/Removed from all Tabs
                    if (allTabsChanged)
                    {
                        var listTabs = TabController.GetPortalTabs(PortalSettings.PortalId, Null.NullInteger, false, true);
                        if (chkAllTabs.Checked)
                        {
                            if (!chkNewTabs.Checked)
                            {
                                foreach (var destinationTab in listTabs)
                                {
                                    var module = ModuleController.Instance.GetModule(_moduleId, destinationTab.TabID, false);
                                    if (module != null)
                                    {
                                        if (module.IsDeleted)
                                        {
                                            ModuleController.Instance.RestoreModule(module);
                                        }
                                    }
                                    else
                                    {
                                        if (!PortalSettings.ContentLocalizationEnabled || (Module.CultureCode == destinationTab.CultureCode))
                                        {
                                            ModuleController.Instance.CopyModule(Module, destinationTab, Module.PaneName, true);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            ModuleController.Instance.DeleteAllModules(_moduleId, TabId, listTabs, true, false, false);
                        }
                    }

                    if (!DoNotRedirectOnUpdate)
                    {
                        //Navigate back to admin page
                        Response.Redirect(ReturnURL, true);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 26
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                btnMonth.Visible = false;
                if (Settings.MonthAllowed && Parent.ID.ToLower() != "eventmonth")
                {
                    btnMonth.Visible       = true;
                    btnMonth.AlternateText = Localization.GetString("MenuMonth", LocalResourceFile);
                    btnMonth.ToolTip       = Localization.GetString("MenuMonth", LocalResourceFile);
                }
                btnWeek.Visible = false;
                if (Settings.WeekAllowed && Parent.ID.ToLower() != "eventweek")
                {
                    btnWeek.Visible       = true;
                    btnWeek.AlternateText = Localization.GetString("MenuWeek", LocalResourceFile);
                    btnWeek.ToolTip       = Localization.GetString("MenuWeek", LocalResourceFile);
                }
                btnList.Visible = false;
                if (Settings.ListAllowed && Parent.ID.ToLower() != "eventlist" &&
                    Parent.ID.ToLower() != "eventrpt")
                {
                    btnList.Visible       = true;
                    btnList.AlternateText = Localization.GetString("MenuList", LocalResourceFile);
                    btnList.ToolTip       = Localization.GetString("MenuList", LocalResourceFile);
                }
                btnEnroll.Visible = false;
                if (Settings.Eventsignup && Parent.ID.ToLower() != "eventmyenrollments")
                {
                    btnEnroll.Visible       = true;
                    btnEnroll.AlternateText = Localization.GetString("MenuMyEnrollments", LocalResourceFile);
                    btnEnroll.ToolTip       = Localization.GetString("MenuMyEnrollments", LocalResourceFile);
                }

                var socialGroupId = GetUrlGroupId();
                var groupStr      = "";
                if (socialGroupId > 0)
                {
                    groupStr = "&GroupId=" + socialGroupId;
                }
                var socialUserId = GetUrlUserId();

                hypiCal.Visible     = Settings.IcalOnIconBar;
                hypiCal.ToolTip     = Localization.GetString("MenuiCal", LocalResourceFile);
                hypiCal.NavigateUrl = "~/DesktopModules/Events/EventVCal.aspx?ItemID=0&Mid=" +
                                      Convert.ToString(ModuleId) + "&tabid=" + Convert.ToString(TabId) +
                                      groupStr;

                btnRSS.Visible     = Settings.RSSEnable;
                btnRSS.ToolTip     = Localization.GetString("MenuRSS", LocalResourceFile);
                btnRSS.NavigateUrl = "~/DesktopModules/Events/EventRSS.aspx?mid=" +
                                     Convert.ToString(ModuleId) + "&tabid=" + Convert.ToString(TabId) +
                                     groupStr;
                btnRSS.Target = "_blank";

                btnAdd.Visible        = false;
                btnModerate.Visible   = false;
                btnSettings.Visible   = false;
                btnCategories.Visible = false;
                btnLocations.Visible  = false;
                btnSubscribe.Visible  = false;
                lblSubscribe.Visible  = false;
                imgBar.Visible        = false;

                if (Request.IsAuthenticated)
                {
                    var objEventInfoHelper =
                        new EventInfoHelper(ModuleId, TabId, PortalId, Settings);

                    //Module Editor.
                    if (IsModuleEditor())
                    {
                        btnAdd.ToolTip = Localization.GetString("MenuAddEvents", LocalResourceFile);
                        if (socialGroupId > 0)
                        {
                            btnAdd.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(
                                    EditUrl("groupid", socialGroupId.ToString(), "Edit"), "?");
                            btnAdd.Visible = true;
                        }
                        else if (socialUserId > 0)
                        {
                            if (socialUserId == UserId || IsModerator())
                            {
                                btnAdd.NavigateUrl =
                                    objEventInfoHelper.AddSkinContainerControls(
                                        EditUrl("Userid", socialUserId.ToString(), "Edit"), "?");
                                btnAdd.Visible = true;
                            }
                        }
                        else
                        {
                            btnAdd.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(EditUrl("Edit"), "?");
                            btnAdd.Visible = true;
                        }
                    }
                    if (Settings.Moderateall &&
                        (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) || IsModerator()))
                    {
                        btnModerate.Visible       = true;
                        btnModerate.AlternateText = Localization.GetString("MenuModerate", LocalResourceFile);
                        btnModerate.ToolTip       = Localization.GetString("MenuModerate", LocalResourceFile);
                    }
                    // Settings Editor.
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) || IsSettingsEditor())
                    {
                        btnSettings.Visible = true;
                        btnSettings.ToolTip = Localization.GetString("MenuSettings", LocalResourceFile);
                        if (socialGroupId > 0)
                        {
                            btnSettings.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(
                                    EditUrl("groupid", socialGroupId.ToString(), "EventSettings"), "?");
                        }
                        else if (socialUserId > 0)
                        {
                            btnSettings.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(
                                    EditUrl("userid", socialUserId.ToString(), "EventSettings"), "?");
                        }
                        else
                        {
                            btnSettings.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(EditUrl("EventSettings"), "?");
                        }
                    }
                    // Categories Editor.
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) || IsCategoryEditor())
                    {
                        btnCategories.Visible = true;
                        btnCategories.ToolTip = Localization.GetString("MenuCategories", LocalResourceFile);
                        if (socialGroupId > 0)
                        {
                            btnCategories.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(
                                    EditUrl("groupid", socialGroupId.ToString(), "Categories"), "?");
                        }
                        else if (socialUserId > 0)
                        {
                            btnCategories.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(
                                    EditUrl("userid", socialUserId.ToString(), "Categories"), "?");
                        }
                        else
                        {
                            btnCategories.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(EditUrl("Categories"), "?");
                        }
                    }
                    // Locations Editor.
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) || IsLocationEditor())
                    {
                        btnLocations.Visible = true;
                        btnLocations.ToolTip = Localization.GetString("MenuLocations", LocalResourceFile);
                        if (socialGroupId > 0)
                        {
                            btnLocations.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(
                                    EditUrl("groupid", socialGroupId.ToString(), "Locations"), "?");
                        }
                        else if (socialUserId > 0)
                        {
                            btnLocations.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(
                                    EditUrl("userid", socialUserId.ToString(), "Locations"), "?");
                        }
                        else
                        {
                            btnLocations.NavigateUrl =
                                objEventInfoHelper.AddSkinContainerControls(EditUrl("Locations"), "?");
                        }
                    }

                    if (Settings.Neweventemails == "Subscribe")
                    {
                        btnSubscribe.Visible = true;
                        lblSubscribe.Visible = true;
                        imgBar.Visible       = true;
                        var objEventSubscriptionController = new EventSubscriptionController();
                        var objEventSubscription           =
                            objEventSubscriptionController.EventsSubscriptionGetUser(UserId, ModuleId);
                        if (ReferenceEquals(objEventSubscription, null))
                        {
                            lblSubscribe.Text          = Localization.GetString("lblSubscribe", LocalResourceFile);
                            btnSubscribe.AlternateText =
                                Localization.GetString("MenuSubscribe", LocalResourceFile);
                            btnSubscribe.ToolTip =
                                Localization.GetString("MenuTTSubscribe", LocalResourceFile);
                            btnSubscribe.ImageUrl = IconController.IconURL("Unchecked");
                        }
                        else
                        {
                            lblSubscribe.Text          = Localization.GetString("lblUnsubscribe", LocalResourceFile);
                            btnSubscribe.AlternateText =
                                Localization.GetString("MenuUnsubscribe", LocalResourceFile);
                            btnSubscribe.ToolTip =
                                Localization.GetString("MenuTTUnsubscribe", LocalResourceFile);
                            btnSubscribe.ImageUrl = IconController.IconURL("Checked");
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// BindData loads the controls from the Database
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void BindData()
        {
            //bind all portal roles to dropdownlist
            if (RoleId == Null.NullInteger)
            {
                if (cboRoles.Items.Count == 0)
                {
                    var roles = RoleController.Instance.GetRoles(PortalId, x => x.Status == RoleStatus.Approved);

                    //Remove access to Admin Role if use is not a member of the role
                    int roleIndex = Null.NullInteger;
                    foreach (RoleInfo tmpRole in roles)
                    {
                        if (tmpRole.RoleName == PortalSettings.AdministratorRoleName)
                        {
                            if (!PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                            {
                                roleIndex = roles.IndexOf(tmpRole);
                            }
                        }
                        break;
                    }
                    if (roleIndex > Null.NullInteger)
                    {
                        roles.RemoveAt(roleIndex);
                    }
                    cboRoles.DataSource = roles;
                    cboRoles.DataBind();
                }
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    if (Role != null)
                    {
                        //cboRoles.Items.Add(new ListItem(Role.RoleName, Role.RoleID.ToString()));
                        cboRoles.AddItem(Role.RoleName, Role.RoleID.ToString());
                        cboRoles.Items[0].Selected = true;
                        lblTitle.Text = string.Format(Localization.GetString("RoleTitle.Text", LocalResourceFile), Role.RoleName, Role.RoleID);
                    }
                    cboRoles.Visible = false;
                    plRoles.Visible  = false;
                }
            }

            //bind all portal users to dropdownlist
            if (UserId == -1)
            {
                //Make sure user has enough permissions
                if (Role.RoleName == PortalSettings.AdministratorRoleName && !PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("NotAuthorized", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                    pnlRoles.Visible     = false;
                    pnlUserRoles.Visible = false;
                    chkNotify.Visible    = false;
                    return;
                }
                if (UsersControl == UsersControl.Combo)
                {
                    if (cboUsers.Items.Count == 0)
                    {
                        foreach (UserInfo objUser in UserController.GetUsers(PortalId))
                        {
                            //cboUsers.Items.Add(new ListItem(objUser.DisplayName + " (" + objUser.Username + ")", objUser.UserID.ToString()));
                            cboUsers.AddItem(objUser.DisplayName + " (" + objUser.Username + ")", objUser.UserID.ToString());
                        }
                    }
                    txtUsers.Visible    = false;
                    cboUsers.Visible    = true;
                    cmdValidate.Visible = false;
                }
                else
                {
                    txtUsers.Visible    = true;
                    cboUsers.Visible    = false;
                    cmdValidate.Visible = true;
                }
            }
            else
            {
                if (User != null)
                {
                    txtUsers.Text = User.UserID.ToString();
                    lblTitle.Text = string.Format(Localization.GetString("UserTitle.Text", LocalResourceFile), User.Username, User.UserID);
                }
                txtUsers.Visible    = false;
                cboUsers.Visible    = false;
                cmdValidate.Visible = false;
                plUsers.Visible     = false;
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                cancelHyperLink.NavigateUrl = ReturnURL;

                if (_moduleId != -1)
                {
                    ctlAudit.Entity = Module;
                }
                if (Page.IsPostBack == false)
                {
                    ctlIcon.FileFilter = Globals.glbImageFileTypes;

                    dgPermissions.TabId    = PortalSettings.ActiveTab.TabID;
                    dgPermissions.ModuleID = _moduleId;


                    cboTab.DataSource = TabController.GetPortalTabs(PortalId, -1, false, Null.NullString, true, false, true, false, true);
                    cboTab.DataBind();

                    //if tab is a  host tab, then add current tab
                    if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        cboTab.InsertItem(0, PortalSettings.ActiveTab.LocalizedTabName, PortalSettings.ActiveTab.TabID.ToString());
                    }
                    if (Module != null)
                    {
                        if (cboTab.FindItemByValue(Module.TabID.ToString()) == null)
                        {
                            var objTab = TabController.Instance.GetTab(Module.TabID, Module.PortalID, false);
                            cboTab.AddItem(objTab.LocalizedTabName, objTab.TabID.ToString());
                        }
                    }

                    //only Portal Administrators can manage the visibility on all Tabs
                    rowAllTabs.Visible = PortalSecurity.IsInRole("Administrators");

                    //tab administrators can only manage their own tab
                    if (!TabPermissionController.CanAdminPage())
                    {
                        chkNewTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllModules.Enabled = false;
                        chkAllowIndex.Enabled = false;
                        cboTab.Enabled        = false;
                    }
                    if (_moduleId != -1)
                    {
                        BindData();
                        cmdDelete.Visible = ModulePermissionController.CanDeleteModule(Module) || TabPermissionController.CanAddContentToPage();
                    }
                    else
                    {
                        isShareableCheckBox.Checked         = true;
                        isShareableViewOnlyCheckBox.Checked = true;
                        isShareableRow.Visible = true;

                        cboVisibility.SelectedIndex = 0; //maximized
                        chkAllTabs.Checked          = false;
                        cmdDelete.Visible           = false;
                    }
                    if (Module != null)
                    {
                        cmdUpdate.Visible      = ModulePermissionController.HasModulePermission(Module.ModulePermissions, "EDIT,MANAGE") || TabPermissionController.CanAddContentToPage();
                        permissionsRow.Visible = ModulePermissionController.CanAdminModule(Module) || TabPermissionController.CanAddContentToPage();
                    }

                    //Set visibility of Specific Settings
                    if (SettingsControl == null == false)
                    {
                        //Get the module settings from the PortalSettings and pass the
                        //two settings hashtables to the sub control to process
                        SettingsControl.LoadSettings();
                        specificSettingsTab.Visible = true;
                        fsSpecific.Visible          = true;
                    }
                    else
                    {
                        specificSettingsTab.Visible = false;
                        fsSpecific.Visible          = false;
                    }

                    if (Module != null)
                    {
                        termsSelector.PortalId = Module.PortalID;
                        termsSelector.Terms    = Module.Terms;
                    }
                    termsSelector.DataBind();
                }
                if (Module != null)
                {
                    cultureLanguageLabel.Language = Module.CultureCode;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 29
0
        protected void OnVersionsGridItemDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var htmlContent = e.Row.DataItem as HtmlTextInfo;
                var createdBy   = "Default";

                if (htmlContent.CreatedByUserID != -1)
                {
                    var createdByByUser = UserController.GetUserById(this.PortalId, htmlContent.CreatedByUserID);
                    if (createdByByUser != null)
                    {
                        createdBy = createdByByUser.DisplayName;
                    }
                }

                foreach (TableCell cell in e.Row.Cells)
                {
                    foreach (Control cellControl in cell.Controls)
                    {
                        if (cellControl is ImageButton)
                        {
                            var imageButton = cellControl as ImageButton;
                            imageButton.CommandArgument = htmlContent.ItemID.ToString();
                            switch (imageButton.CommandName.ToLowerInvariant())
                            {
                            case "rollback":
                                // hide rollback for the first item
                                if (this.dgVersions.CurrentPageIndex == 0)
                                {
                                    if (e.Row.RowIndex == 0)
                                    {
                                        imageButton.Visible = false;
                                        break;
                                    }
                                }

                                imageButton.Visible = true;

                                break;

                            case "remove":
                                var msg = this.GetLocalizedString("DeleteVersion.Confirm");
                                msg =
                                    msg.Replace("[VERSION]", htmlContent.Version.ToString()).Replace("[STATE]", htmlContent.StateName).Replace("[DATECREATED]", htmlContent.CreatedOnDate.ToString())
                                    .Replace("[USERNAME]", createdBy);
                                imageButton.OnClientClick = "return confirm(\"" + msg + "\");";

                                // hide the delete button
                                var showDelete = this.UserInfo.IsSuperUser || PortalSecurity.IsInRole(this.PortalSettings.AdministratorRoleName);

                                if (!showDelete)
                                {
                                    showDelete = htmlContent.IsPublished == false;
                                }

                                imageButton.Visible = showDelete;
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
 protected bool CanEdit()
 {
     return(PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName));
 }