Esempio n. 1
0
 /// <summary>
 /// Returns a flag indicating whether the current user can manage a module's settings
 /// </summary>
 /// <param name="module">The page</param>
 /// <returns>A flag indicating whether the user has permission</returns>
 public virtual bool CanManageModule(ModuleInfo module)
 {
     return(PortalSecurity.IsInRoles(module.ModulePermissions.ToString(ManageModulePermissionKey)));
 }
        /// <summary>
        /// Handles the Load event of the DesktopDefault control.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        private void DesktopDefault_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.Params["panelist"]))
            {
                this.RenderContentAreaList();
            }
            // intento obtener el id de la pagina desde el query
            string query  = Request.Url.Query;
            int    pageId = 0;

            if (query.Contains("?") && query.ToLower().Contains("pageid"))
            {
                int index       = query.IndexOf('?');
                int indexPageId = query.ToLower().IndexOf("pageid") + 5;
                if (index < indexPageId - 5)
                {
                    query = query.Substring(indexPageId + 2, query.Length - indexPageId - 2);
                    index = query.IndexOf('&');
                    if (index > 0) // no va hasta el final el numero de pagina
                    {
                        query = query.Substring(0, index);
                    }
                    try
                    {
                        pageId = int.Parse(query);
                    }
                    catch (Exception)
                    {
                        pageId = 0;
                    }
                }
                else
                {
                    pageId = 0;
                }
            }
            else
            {
                pageId = this.PortalSettings.ActivePage.PageID;
            }

            if (pageId == 0)
            {
                pageId = Convert.ToInt32(SiteMap.RootNode.ChildNodes[0].Key);
                this.Response.Redirect(HttpUrlBuilder.BuildUrl(pageId));
            }

            string urlToRedirect = "";
            bool   redirect      = HttpUrlBuilder.ValidateProperUrl(pageId, ref urlToRedirect);

            if (!redirect)
            {
                this.Response.Redirect(urlToRedirect);
            }

            if (!PortalSecurity.IsInRoles(this.PortalSettings.ActivePage.AuthorizedRoles) &&
                !this.User.IsInRole("Admins"))
            {
                PortalSecurity.AccessDenied();
            }
            else
            {
                if (this.Request.Params["r"] == null || this.Request.Params["r"] != "0")
                {
                    var user = Membership.GetUser();
                }

                var userName = this.Request.Params["u"];
                var pass     = this.Request.Params["p"];
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(pass))
                {
                    // PortalSecurity.SignOn(userName, pass, false, "~/DesktopDefault.aspx");
                    var rem = (this.Request.Params["rem"] ?? "0").Equals("1") ? true : false;
                    PortalSecurity.SignOn(userName, pass, rem, "~/DesktopDefault.aspx");
                    this.Response.Redirect("~/DesktopDefault.aspx");
                }


                if (string.IsNullOrEmpty(Request.Params["panelist"]))
                {
                    this.LoadPage();
                }
            }
        }
Esempio n. 3
0
            public static List <string> GetCultureListItems()
            {
                List <string> Languages = new List <string>();

                try
                {
                    IEnumerable <System.Web.UI.WebControls.ListItem> cultureListItems = DotNetNuke.Services.Localization.Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, CultureInfo.CurrentCulture.ToString(), "", false);
                    PortalSettings ps = PortalController.Instance.GetCurrentSettings() as PortalSettings;
                    foreach (Locale loc in LocaleController.Instance.GetLocales(ps.PortalId).Values)
                    {
                        string defaultRoles = PortalController.GetPortalSetting(string.Format("DefaultTranslatorRoles-{0}", loc.Code), ps.PortalId, "Administrators");
                        if (!ps.ContentLocalizationEnabled || (LocaleIsAvailable(loc) && (PortalSecurity.IsInRoles(ps.AdministratorRoleName) || loc.IsPublished || PortalSecurity.IsInRoles(defaultRoles))))
                        {
                            foreach (System.Web.UI.WebControls.ListItem cultureItem in cultureListItems)
                            {
                                if (cultureItem.Value == loc.Code)
                                {
                                    Languages.Add(loc.Code);
                                }
                            }
                        }
                    }
                }
                catch
                {
                }

                return(Languages);
            }
Esempio n. 4
0
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <history>
        ///     [cnurse]	10/18/2004	documented
        ///     [cnurse]	10/19/2004	modified to support custm module specific settings
        ///     [vmasanas]  11/28/2004  modified to support modules in admin tabs
        /// </history>
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                // Verify that the current user has access to edit this module
                if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) == false && PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString()) == false)
                {
                    Response.Redirect(Globals.NavigateURL("Access Denied"), true);
                }

                //this needs to execute always to the client script code is registred in InvokePopupCal
                cmdStartCalendar.NavigateUrl = Calendar.InvokePopupCal(txtStartDate);
                cmdEndCalendar.NavigateUrl   = Calendar.InvokePopupCal(txtEndDate);

                if (Page.IsPostBack == false)
                {
                    ctlIcon.FileFilter = Globals.glbImageFileTypes;

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

                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));

                    cboTab.DataSource = Globals.GetPortalTabs(PortalSettings.DesktopTabs, -1, false, true, false, false, true);
                    cboTab.DataBind();
                    //if is and admin or host tab, then add current tab
                    if (PortalSettings.ActiveTab.ParentId == PortalSettings.AdminTabId || PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId)
                    {
                        cboTab.Items.Insert(0, new ListItem(PortalSettings.ActiveTab.TabName, PortalSettings.ActiveTab.TabID.ToString()));
                    }

                    // tab administrators can only manage their own tab
                    if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) == false)
                    {
                        chkAllTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllModules.Enabled = false;
                        cboTab.Enabled        = false;
                    }

                    if (moduleId != -1)
                    {
                        BindData();
                    }
                    else
                    {
                        cboVisibility.SelectedIndex = 0; // maximized
                        chkAllTabs.Checked          = false;
                        cmdDelete.Visible           = false;
                    }

                    //Set visibility of Specific Settings
                    if (ctlSpecific != null)
                    {
                        //Get the module settings from the PortalSettings and pass the
                        //two settings hashtables to the sub control to process
                        ctlSpecific.LoadSettings();
                        dshSpecific.Visible = true;
                        tblSpecific.Visible = true;
                    }
                    else
                    {
                        dshSpecific.Visible = false;
                        tblSpecific.Visible = false;
                    }
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        private bool IsReviewer(UserInfo user, PortalSettings settings, IEnumerable <ContentWorkflowStatePermission> permissions)
        {
            var administratorRoleName = settings.AdministratorRoleName;

            return(user.IsSuperUser || PortalSecurity.IsInRoles(user, settings, administratorRoleName) || PortalSecurity.IsInRoles(user, settings, PermissionController.BuildPermissions(permissions.ToList(), "REVIEW")));
        }
 public virtual bool CanViewModule(ModuleInfo objModule)
 {
     return(PortalSecurity.IsInRoles(objModule.ModulePermissions.ToString(ViewModulePermissionCode)));
 }
 public virtual bool HasTabPermission(Security.Permissions.TabPermissionCollection objTabPermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objTabPermissions.ToString(permissionKey)));
 }
Esempio n. 8
0
        /// <summary>
        /// The BindData helper method is used to update the tab's
        ///   layout panes with the current configuration information
        /// </summary>
        /// <remarks>
        /// </remarks>
        private void BindData()
        {
            var page = this.PortalSettings.ActivePage;

            // Populate Page Names, etc.
            this.txtPageID.Text          = page.PageID.ToString();
            this.tabName.Text            = page.PageName;
            this.friendlyUrl.Text        = page.FriendlyURL;
            this.mobilePageName.Text     = page.MobilePageName;
            this.showMobile.Checked      = page.ShowMobile;
            this.lblCurrentPageLink.Text = HttpUrlBuilder.BuildUrl(page.PageID);

            // Populate the "ParentPage" Data
            var t     = new PagesDB();
            var items = t.GetPagesParent(this.PortalSettings.PortalID, this.PageID);

            this.parentPage.DataSource = items;
            this.parentPage.DataBind();

            if (this.parentPage.Items.FindByValue(page.ParentPageID.ToString()) != null)
            {
                // parentPage.Items.FindByValue( tab.ParentPageID.ToString() ).Selected = true;
                this.parentPage.SelectedValue = page.ParentPageID.ToString();
            }

            // Translate
            if (this.parentPage.Items.FindByText(" ROOT_LEVEL") != null)
            {
                this.parentPage.Items.FindByText(" ROOT_LEVEL").Text = General.GetString(
                    "ROOT_LEVEL", "Root Level", this.parentPage);
            }

            // Populate checkbox list with all security roles for this portal
            // and "check" the ones already configured for this tab
            var users = new UsersDB();
            var roles = users.GetPortalRoles(this.PortalSettings.PortalAlias);

            // Clear existing items in checkboxlist
            this.authRoles.Items.Clear();

            foreach (var role in roles)
            {
                var item = new ListItem();
                item.Text  = role.Name;
                item.Value = role.Id.ToString();

                if (page.AuthorizedRoles.LastIndexOf(item.Text) > -1)
                {
                    item.Selected = true;
                }

                this.authRoles.Items.Add(item);
            }

            // Populate the "Add Module" Data
            var m       = new ModulesDB();
            var modules = new SortedList <string, string>();
            var drCurrentModuleDefinitions = m.GetCurrentModuleDefinitions(this.PortalSettings.PortalID);
            var htmlId = "0";

            try
            {
                foreach (var item in drCurrentModuleDefinitions)
                {
                    if ((!modules.ContainsKey(item.FriendlyName)) &&
                        (PortalSecurity.IsInRoles("Admins") || !item.Admin))
                    {
                        modules.Add(

                            item.FriendlyName,
                            item.ModuleDefId.ToString());
                        if (item.FriendlyName.ToString().Equals("HTML Content"))
                        {
                            htmlId = item.ModuleDefId.ToString();
                        }
                    }
                }
            }
            finally
            {
            }

            this.moduleType.DataSource = modules;
            this.moduleType.DataBind();
            this.moduleType.SelectedValue = htmlId;
        }
Esempio n. 9
0
        private static SavedFileDTO SaveFile(
            Stream stream,
            PortalSettings portalSettings,
            UserInfo userInfo,
            string folder,
            string filter,
            string fileName,
            bool overwrite,
            bool isHostMenu,
            bool extract,
            out bool alreadyExists,
            out string errorMessage)
        {
            alreadyExists = false;
            var savedFileDto = new SavedFileDTO();

            try
            {
                var extension = Path.GetExtension(fileName).ValueOrEmpty().Replace(".", "");
                if (!string.IsNullOrEmpty(filter) && !filter.ToLower().Contains(extension.ToLower()))
                {
                    errorMessage = GetLocalizedString("ExtensionNotAllowed");
                    return(savedFileDto);
                }

                var folderManager = FolderManager.Instance;

                // Check if this is a User Folder
                var effectivePortalId = isHostMenu ? Null.NullInteger : PortalController.GetEffectivePortalId(portalSettings.PortalId);
                int userId;
                var folderInfo = folderManager.GetFolder(effectivePortalId, folder);
                if (IsUserFolder(folder, out userId))
                {
                    var user = UserController.GetUserById(effectivePortalId, userId);
                    if (user != null)
                    {
                        folderInfo = folderManager.GetUserFolder(user);
                    }
                }

                if (!PortalSecurity.IsInRoles(userInfo, portalSettings, folderInfo.FolderPermissions.ToString("WRITE")) &&
                    !PortalSecurity.IsInRoles(userInfo, portalSettings, folderInfo.FolderPermissions.ToString("ADD")))
                {
                    errorMessage = GetLocalizedString("NoPermission");
                    return(savedFileDto);
                }

                if (!overwrite && FileManager.Instance.FileExists(folderInfo, fileName, true))
                {
                    errorMessage          = GetLocalizedString("AlreadyExists");
                    alreadyExists         = true;
                    savedFileDto.FilePath = Path.Combine(folderInfo.PhysicalPath, fileName);
                    return(savedFileDto);
                }

                var contentType = FileContentTypeManager.Instance.GetContentType(Path.GetExtension(fileName));
                var file        = FileManager.Instance.AddFile(folderInfo, fileName, stream, true, false, contentType, userInfo.UserID);

                if (extract && extension.ToLower() == "zip")
                {
                    FileManager.Instance.UnzipFile(file);
                    FileManager.Instance.DeleteFile(file);
                }

                errorMessage          = "";
                savedFileDto.FileId   = file.FileId.ToString(CultureInfo.InvariantCulture);
                savedFileDto.FilePath = FileManager.Instance.GetUrl(file);
                return(savedFileDto);
            }
            catch (InvalidFileExtensionException)
            {
                errorMessage = GetLocalizedString("ExtensionNotAllowed");
                return(savedFileDto);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                errorMessage = ex.Message;
                return(savedFileDto);
            }
        }
        /// <summary>
        /// This method determines the tab index of the currently
        /// requested portal view, and then dynamically populate the left,
        /// center and right hand sections of the portal tab.
        /// </summary>
        protected override void InitializeDataSource()
        {
            base.InitializeDataSource();

            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            // Dynamically Populate the Left, Center and Right pane sections of the portal page
            if (portalSettings.ActivePage.Modules.Count > 0)
            {
                // Loop through each entry in the configuration system for this tab
                foreach (ModuleSettings _moduleSettings in portalSettings.ActivePage.Modules)
                {
                    if (!_moduleSettings.Cacheable)
                    {
                        _moduleSettings.CacheTime = -1;                             // Disable cache
                    }
                    // NEW MODULE_VIEW PERMISSIONS ADDED
                    // Ensure that the visiting user has access to view the current module
                    if (PortalSecurity.IsInRoles(_moduleSettings.AuthorizedViewRoles) == true)
                    {
                        ArrayList arrayData;

                        switch (_moduleSettings.PaneName.ToLower())
                        {
                        case "leftpane":
                            arrayData = DataSource[IDX_LEFT_PANE_DATA];
                            break;

                        case "contentpane":
                            arrayData = DataSource[IDX_CONTENT_PANE_DATA];
                            break;

                        case "rightpane":
                            arrayData = DataSource[IDX_RIGHT_PANE_DATA];
                            break;

                        default:
                            arrayData = DataSource[IDX_CONTENT_PANE_DATA];
                            break;
                        }

                        // If no caching is specified, create the user control instance and dynamically
                        // inject it into the page.  Otherwise, create a cached module instance that
                        // may or may not optionally inject the module into the tree

                        //Cache. If == 0 then override with default cache in web.config
// jes1111
//						if(ConfigurationSettings.AppSettings["ModuleOverrideCache"] != null
//							&& !_moduleSettings.Admin
//							&& _moduleSettings.CacheTime == 0)
                        if (!_moduleSettings.Admin && _moduleSettings.CacheTime == 0)
                        {
                            //jes1111 - int mCache = Int32.Parse(ConfigurationSettings.AppSettings["ModuleOverrideCache"]);
                            int mCache = Config.ModuleOverrideCache;
                            if (mCache > 0)
                            {
                                _moduleSettings.CacheTime = mCache;
                            }
                        }

                        // Change 28/Feb/2003 Jeremy Esland - added security settings to condition test so that a user who has
                        // edit or properties permission will not cause the module output to be cached.
                        if (
                            ((_moduleSettings.CacheTime) <= 0) ||
                            (PortalSecurity.HasEditPermissions(_moduleSettings.ModuleID)) ||
                            (PortalSecurity.HasPropertiesPermissions(_moduleSettings.ModuleID)) ||
                            (PortalSecurity.HasAddPermissions(_moduleSettings.ModuleID)) ||
                            (PortalSecurity.HasDeletePermissions(_moduleSettings.ModuleID))
                            )
                        {
                            try
                            {
                                string portalModuleName =
                                    string.Concat(Path.ApplicationRoot, "/", _moduleSettings.DesktopSrc);
                                PortalModuleControl portalModule =
                                    (PortalModuleControl)Page.LoadControl(portalModuleName);

                                portalModule.PortalID            = portalSettings.PortalID;
                                portalModule.ModuleConfiguration = _moduleSettings;

                                //TODO: This is not the best place: should be done early
                                if (portalModule.Cultures == string.Empty ||
                                    (portalModule.Cultures + ";").IndexOf(portalSettings.PortalContentLanguage.Name +
                                                                          ";") >= 0)
                                {
                                    arrayData.Add(portalModule);
                                }
                            }
                            catch (Exception ex)
                            {
                                //ErrorHandler.HandleException("DesktopPanes: Unable to load control '" + _moduleSettings.DesktopSrc + "'!", ex);
                                ErrorHandler.Publish(LogLevel.Error,
                                                     "DesktopPanes: Unable to load control '" +
                                                     _moduleSettings.DesktopSrc + "'!", ex); // jes1111
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" + "Unable to load control '" +
                                                           _moduleSettings.DesktopSrc +
                                                           "'! (Full Error Logged)<br />Error Message: " +
                                                           ex.Message.ToString()));
                                }
                                else
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" + "Unable to load control '" +
                                                           _moduleSettings.DesktopSrc + "'!"));
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                using (CachedPortalModuleControl portalModule = new CachedPortalModuleControl())
                                {
                                    portalModule.PortalID            = portalSettings.PortalID;
                                    portalModule.ModuleConfiguration = _moduleSettings;

                                    arrayData.Add(portalModule);
                                }
                            }
                            catch (Exception ex)
                            {
                                //ErrorHandler.HandleException("DesktopPanes: Unable to load cached control '" + _moduleSettings.DesktopSrc + "'!", ex);
                                ErrorHandler.Publish(LogLevel.Error,
                                                     "DesktopPanes: Unable to load cached control '" +
                                                     _moduleSettings.DesktopSrc + "'!", ex);
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" +
                                                           "Unable to load cached control '" +
                                                           _moduleSettings.DesktopSrc +
                                                           "'! (Full Error Logged)<br />Error Message: " +
                                                           ex.Message.ToString()));
                                }
                                else
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" +
                                                           "Unable to load cached control '" +
                                                           _moduleSettings.DesktopSrc + "'!"));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Convert the module list to dictionary.
        /// </summary>
        /// <param name="modules"></param>
        /// <returns>A dictionary</returns>
        /// <exception cref="Exception"></exception>
        private static Dictionary <string, List <Control> > ConvertModuleListToDictionary(List <IModuleSettings> modules)
        {
            var     settings     = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
            var     dictionary   = new Dictionary <string, List <Control> >();
            dynamic faultyModule = null;
            var     modErrKey    = HttpContext.Current.Request.Params["modErr"];

            //we receive this param if in the Application_Error it was discovered that a module is broken
            if (!string.IsNullOrEmpty(modErrKey))
            {
                faultyModule = HttpContext.Current.Cache.Get(modErrKey);
                HttpContext.Current.Cache.Remove(modErrKey);
            }

            if (modules.Count > 0)
            {
                var page = new Page();
                foreach (ModuleSettings settings2 in modules)
                {
                    if (!settings2.Cacheable)
                    {
                        settings2.CacheTime = -1;
                    }

                    if (PortalSecurity.IsInRoles(settings2.AuthorizedViewRoles))
                    {
                        List <Control> list;
                        Exception      exception;
                        var            str = settings2.PaneName.ToLower();
                        if (!string.IsNullOrEmpty(str))
                        {
                            if (!dictionary.ContainsKey(str))
                            {
                                dictionary.Add(str, new List <Control>());
                            }

                            list = dictionary[str];
                        }
                        else
                        {
                            if (!dictionary.ContainsKey("contentpane"))
                            {
                                dictionary.Add("contentpane", new List <Control>());
                            }

                            list = dictionary["contentpane"];
                        }

                        if (!settings2.Admin && (settings2.CacheTime == 0))
                        {
                            var moduleOverrideCache = Config.ModuleOverrideCache;
                            if (moduleOverrideCache > 0)
                            {
                                settings2.CacheTime = moduleOverrideCache;
                            }
                        }

                        if ((((settings2.CacheTime <= 0) || PortalSecurity.HasEditPermissions(settings2.ModuleID)) ||
                             (PortalSecurity.HasPropertiesPermissions(settings2.ModuleID) ||
                              PortalSecurity.HasAddPermissions(settings2.ModuleID))) ||
                            PortalSecurity.HasDeletePermissions(settings2.ModuleID))
                        {
                            try
                            {
                                PortalModuleControl control;
                                var virtualPath = Path.ApplicationRoot + "/" + settings2.DesktopSrc;
                                if (virtualPath.ToLowerInvariant().Trim().EndsWith(".ascx"))
                                {
                                    if (faultyModule != null && faultyModule.ModuleDefID == settings2.ModuleDefID)
                                    {
                                        throw new Exception(faultyModule.Message); //if this was the module that was generating the error, we then show the error.
                                    }
                                    control = (PortalModuleControl)page.LoadControl(virtualPath);
                                }
                                else
                                {
                                    var strArray = virtualPath.Split(
                                        new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
                                    int index = 1;
                                    if (!Path.ApplicationRoot.Equals(string.Empty))
                                    {
                                        index++;
                                    }
                                    var areaName       = (strArray[index].ToLower() == "views") ? string.Empty : strArray[index];
                                    var controllerName = strArray[strArray.Length - 2];
                                    var actionName     = strArray[strArray.Length - 1];

                                    // var ns = strArray[2];
                                    control =
                                        (PortalModuleControl)
                                        page.LoadControl("~/DesktopModules/CoreModules/MVC/MVCModule.ascx");

                                    ((MVCModuleControl)control).ControllerName = controllerName;
                                    ((MVCModuleControl)control).ActionName     = actionName;
                                    ((MVCModuleControl)control).AreaName       = areaName;
                                    ((MVCModuleControl)control).ModID          = settings2.ModuleID;

                                    ((MVCModuleControl)control).Initialize();
                                }

                                control.PortalID            = settings.PortalID;
                                control.ModuleConfiguration = settings2;
                                if ((control.Cultures == string.Empty) ||
                                    ((control.Cultures + ";").IndexOf(settings.PortalContentLanguage.Name + ";") >= 0))
                                {
                                    list.Add(control);
                                }
                            }
                            catch (Exception exception1)
                            {
                                exception = exception1;
                                ErrorHandler.Publish(
                                    LogLevel.Error,
                                    string.Format("DesktopPanes: Unable to load control '{0}'!", settings2.DesktopSrc),
                                    exception);
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load control '{0}'! (Full Error Logged)<br />Error Message: {1}", settings2.DesktopSrc, exception.Message)));
                                }
                                else
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load control '{0}'!", settings2.DesktopSrc)));
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                using (var control2 = new CachedPortalModuleControl())
                                {
                                    control2.PortalID            = settings.PortalID;
                                    control2.ModuleConfiguration = settings2;
                                    list.Add(control2);
                                }
                            }
                            catch (Exception exception2)
                            {
                                exception = exception2;
                                ErrorHandler.Publish(
                                    LogLevel.Error,
                                    string.Format("DesktopPanes: Unable to load cached control '{0}'!", settings2.DesktopSrc),
                                    exception);
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load cached control '{0}'! (Full Error Logged)<br />Error Message: {1}", settings2.DesktopSrc, exception.Message)));
                                }
                                else
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load cached control '{0}'!", settings2.DesktopSrc)));
                                }
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }
Esempio n. 12
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            selectCulture.SelectedIndexChanged += selectCulture_SelectedIndexChanged;
            rptLanguages.ItemDataBound         += rptLanguages_ItemDataBound;

            try
            {
                if (ShowLinks)
                {
                    var locales = new Dictionary <string, Locale>();
                    foreach (Locale loc in LocaleController.Instance.GetLocales(PortalSettings.PortalId).Values)
                    {
                        string defaultRoles = PortalController.GetPortalSetting(string.Format("DefaultTranslatorRoles-{0}", loc.Code), PortalSettings.PortalId, "Administrators");
                        if (!PortalSettings.ContentLocalizationEnabled ||
                            (LocaleIsAvailable(loc) &&
                             (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) || loc.IsPublished || PortalSecurity.IsInRoles(defaultRoles))))
                        {
                            locales.Add(loc.Code, loc);
                        }
                    }
                    if (locales.Count > 1)
                    {
                        rptLanguages.DataSource = locales.Values;
                        rptLanguages.DataBind();
                    }
                    else
                    {
                        rptLanguages.Visible = false;
                    }
                }

                if (ShowMenu)
                {
                    if (!String.IsNullOrEmpty(CssClass))
                    {
                        selectCulture.CssClass = CssClass;
                    }
                    Localization.LoadCultureDropDownList(selectCulture, CultureDropDownTypes.NativeName, CurrentCulture);

                    //only show language selector if more than one language
                    if (selectCulture.Items.Count <= 1)
                    {
                        selectCulture.Visible = false;
                    }
                }
                else
                {
                    selectCulture.Visible = false;
                }
                handleCommonTemplates();
            }
            catch (Exception ex)
            {
                Exceptions.ProcessPageLoadException(ex, Request.RawUrl);
            }
        }
        // Override CreateChildControls to create the control tree.
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            // jes1111
            if (!((Page)Page).IsCssFileRegistered("Mod_Breadcrumbs"))
            {
                ((Page)Page).RegisterCssFile("Mod_Breadcrumbs");
            }


            // Create an arraylist to fill with
            // the PageItems representing the Tree
            ArrayList crumbs;

            if (HttpContext.Current != null)
            {
                // Obtain PortalSettings from Current Context
                PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

                //Changes by Indah Fuldner 25.04.2003
                //Display breadcrumbs if the user has click a tab link  (Without hit the Database again)
                if (portalSettings.ActivePage.PageID > 0)
                {
                    ArrayList authorizedTabs = new ArrayList();
                    int       addedTabs      = 0;
                    for (int i = 0; i < portalSettings.DesktopPages.Count; i++)
                    {
                        PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i];

                        if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                        {
                            authorizedTabs.Add(tab);
                        }
                        addedTabs++;
                    }

                    crumbs = GetBreadCrumbs(portalSettings.ActivePage, authorizedTabs);
                    //crumbs.Sort();
                    //Fixing bug: http://support.rainbowportal.net/jira/browse/RBP-704
                    crumbs.Reverse();
                    //End Changes by Indah Fuldner
                }
                else
                {
                    crumbs = new ArrayList();
                }
            }
            else //design time
            {
                crumbs = new ArrayList();
                crumbs.Add("Item1");
                crumbs.Add("Item2");
                crumbs.Add("Item3");
            }

            if (crumbs.Count > 1)
            {
                TableRow  r = new TableRow();
                TableCell c = new TableCell();
                c.CssClass = "breadcrumbs";

                int ct = 0;

                // Build the Breadcrumbs and add them to the table
                foreach (PageItem item in crumbs)
                {
                    if (ct > 0)
                    {
                        Label divider = new Label();
                        divider.Text            = Separator;
                        divider.CssClass        = TextCSSClass;
                        divider.EnableViewState = false;
                        c.Controls.Add(divider);
                    }
                    if (ct != (crumbs.Count - 1))
                    {
                        HyperLink link = new HyperLink();
                        link.Text            = item.Name;
                        link.NavigateUrl     = HttpUrlBuilder.BuildUrl(item.ID);
                        link.EnableViewState = false;
                        link.CssClass        = LinkCSSClass;
                        c.Controls.Add(link);
                    }
                    else
                    {
                        Label lastlink = new Label();
                        lastlink.Text            = item.Name;
                        lastlink.CssClass        = LinkCSSClass;
                        lastlink.EnableViewState = false;
                        c.Controls.Add(lastlink);
                    }
                    ct++;
                }

                r.Cells.Add(c);
                Rows.Add(r);
            }
            else
            {
                Visible = false;
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Returns a flag indicating whether the current user can administer a page
 /// </summary>
 /// <param name="tab">The page</param>
 /// <returns>A flag indicating whether the user has permission</returns>
 public virtual bool CanAdminPage(TabInfo tab)
 {
     return(PortalSecurity.IsInRoles(tab.TabPermissions.ToString(AdminPagePermissionKey)));
 }
 public virtual bool HasFolderPermission(FolderPermissionCollection objFolderPermissions, string PermissionKey)
 {
     return(PortalSecurity.IsInRoles(objFolderPermissions.ToString(PermissionKey)));
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasDesktopModulePermission checks whether the current user has a specific DesktopModule Permission
 /// </summary>
 /// <param name="objDesktopModulePermissions">The Permissions for the DesktopModule</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 ///     [cnurse]	01/15/2008   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public static bool HasDesktopModulePermission(DesktopModulePermissionCollection objDesktopModulePermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objDesktopModulePermissions.ToString(permissionKey)));
 }
 public virtual bool CanEditModuleContent(ModuleInfo objModule)
 {
     return(PortalSecurity.IsInRoles(objModule.ModulePermissions.ToString(ContentModulePermissionCode)));
 }
Esempio n. 18
0
        private bool CanEditModule()
        {
            bool             blnCanEdit = false;
            PortalModuleBase objModule  = Container.GetPortalModuleBase(this);

            if ((objModule != null) && (objModule.ModuleId > Null.NullInteger))
            {
                blnCanEdit = (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) || PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString())) && Globals.IsAdminControl() == false && PortalSettings.ActiveTab.IsAdminTab == false;
            }
            return(blnCanEdit);
        }
 public virtual bool CanViewPage(TabInfo objTab)
 {
     return(PortalSecurity.IsInRoles(objTab.TabPermissions.ToString(ViewPagePermissionCode)));
 }
Esempio n. 20
0
        public HttpResponseMessage GetSecurityBulletins()
        {
            try
            {
                var    plartformVersion = System.Reflection.Assembly.LoadFrom(Globals.ApplicationMapPath + @"\bin\DotNetNuke.dll").GetName().Version;
                string sRequest         = string.Format("http://update.dotnetnuke.com/security.aspx?type={0}&name={1}&version={2}",
                                                        DotNetNukeContext.Current.Application.Type,
                                                        "DNNCORP.CE",
                                                        Globals.FormatVersion(plartformVersion, "00", 3, ""));

                //format for display with "." delimiter
                string sVersion = Globals.FormatVersion(plartformVersion, "00", 3, ".");

                // make remote request
                Stream oStream = null;
                try
                {
                    HttpWebRequest oRequest = Globals.GetExternalRequest(sRequest);
                    oRequest.Timeout = 10000; // 10 seconds
                    WebResponse oResponse = oRequest.GetResponse();
                    oStream = oResponse.GetResponseStream();
                }
                catch (Exception oExc)
                {
                    // connectivity issues
                    if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleId.ToString()))
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, string.Format(Localization.GetString("RequestFailed_Admin.Text", Components.Constants.LocalResourcesFile), sRequest)));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Localization.GetString("RequestFailed_User.Text", Components.Constants.LocalResourcesFile) + oExc.Message));
                    }
                }

                // load XML document
                StreamReader oReader = new StreamReader(oStream);
                XmlDocument  oDoc    = new XmlDocument();
                oDoc.LoadXml(oReader.ReadToEnd());

                List <object> items = new List <object>();
                foreach (XmlNode selectNode in oDoc.SelectNodes(BULLETIN_XMLNODE_PATH))
                {
                    items.Add(new
                    {
                        Title       = selectNode.SelectSingleNode("title") != null ? selectNode.SelectSingleNode("title").InnerText : "",
                        Link        = selectNode.SelectSingleNode("link") != null ? selectNode.SelectSingleNode("link").InnerText : "",
                        Description = selectNode.SelectSingleNode("description") != null ? selectNode.SelectSingleNode("description").InnerText : "",
                        Author      = selectNode.SelectSingleNode("author") != null ? selectNode.SelectSingleNode("author").InnerText : "",
                        PubDate     = selectNode.SelectSingleNode("pubDate") != null ? selectNode.SelectSingleNode("pubDate").InnerText.Split(' ')[0] : ""
                    });
                }

                var response = new
                {
                    Success = true,
                    Results = new
                    {
                        PlatformVersion   = sVersion,
                        SecurityBulletins = items
                    }
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 ///   HasWorkflowStatePermission checks whether the current user has a specific WorkflowState Permission
 /// </summary>
 /// <param name = "objWorkflowStatePermissions">The Permissions for the WorkflowState</param>
 /// <param name = "permissionKey">The Permission to check</param>
 /// <history>
 /// </history>
 /// -----------------------------------------------------------------------------
 public static bool HasWorkflowStatePermission(WorkflowStatePermissionCollection objWorkflowStatePermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objWorkflowStatePermissions.ToString(permissionKey)));
 }
Esempio n. 22
0
        /// <summary>
        /// The RightLeft_Click server event handler on this page is
        ///   used to move a portal module between layout panes on
        ///   the tab page
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="T:System.Web.UI.ImageClickEventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// </remarks>
        protected void RightLeft_Click(object sender, ImageClickEventArgs e)
        {
            var sourcePane = ((ImageButton)sender).Attributes["sourcepane"];
            var targetPane = ((ImageButton)sender).Attributes["targetpane"];
            var sourceBox  = (ListBox)this.Page.FindControl(sourcePane);

            if (sourceBox == null)
            {
                sourceBox = (ListBox)this.Page.Master.FindControl("Content").FindControl(sourcePane);
            }

            var targetBox = (ListBox)this.Page.FindControl(targetPane);

            if (targetBox == null)
            {
                targetBox = (ListBox)this.Page.Master.FindControl("Content").FindControl(targetPane);
            }

            if (sourceBox.SelectedIndex != -1)
            {
                // get source arraylist
                var sourceList = this.GetModules(sourcePane);

                // get a reference to the module to move
                // and assign a high order number to send it to the end of the target list
                var m = (ModuleItem)sourceList[sourceBox.SelectedIndex];

                if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
                {
                    // add it to the database
                    var admin = new ModulesDB();
                    admin.UpdateModuleOrder(m.ID, 99, targetPane);

                    // delete it from the source list
                    sourceList.RemoveAt(sourceBox.SelectedIndex);

                    // reload the portalSettings from the database
                    HttpContext.Current.Items["PortalSettings"] = PortalSettings.GetPortalSettings(
                        this.PageID, this.PortalSettings.PortalAlias);
                    this.PortalSettings = (PortalSettings)this.Context.Items["PortalSettings"];

                    // reorder the modules in the source pane
                    sourceList = this.GetModules(sourcePane);
                    this.OrderModules(sourceList);

                    // resave the order
                    foreach (ModuleItem item in sourceList)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, sourcePane);
                    }

                    // reorder the modules in the target pane
                    var targetList = this.GetModules(targetPane);
                    this.OrderModules(targetList);

                    // resave the order
                    foreach (ModuleItem item in targetList)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, targetPane);
                    }

                    // Redirect to the same page to pick up changes
                    this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID));
                }
                else
                {
                    this.msgError.Visible = true;
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// cmdUpdate_Click runs when the Update LinkButton is clicked.
        /// It saves the current Site Settings
        /// </summary>
        /// <history>
        ///     [cnurse]	10/18/2004	documented
        ///     [cnurse]	10/19/2004	modified to support custm module specific settings
        /// </history>
        protected void cmdUpdate_Click(object Sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    ModuleController objModules     = new ModuleController();
                    bool             AllTabsChanged = false;

                    // tab administrators can only manage their own tab
                    if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) == false)
                    {
                        chkAllTabs.Enabled    = false;
                        chkDefault.Enabled    = false;
                        chkAllModules.Enabled = false;
                        cboTab.Enabled        = false;
                    }

                    // update module
                    ModuleInfo objModule = objModules.GetModule(moduleId, TabId, false);

                    objModule.ModuleID    = moduleId;
                    objModule.ModuleTitle = txtTitle.Text;
                    objModule.Alignment   = cboAlign.SelectedItem.Value;
                    objModule.Color       = txtColor.Text;
                    objModule.Border      = txtBorder.Text;
                    objModule.IconFile    = ctlIcon.Url;
                    if (!String.IsNullOrEmpty(txtCacheTime.Text))
                    {
                        objModule.CacheTime = int.Parse(txtCacheTime.Text);
                    }
                    else
                    {
                        objModule.CacheTime = 0;
                    }
                    objModule.TabID = TabId;
                    if (objModule.AllTabs != chkAllTabs.Checked)
                    {
                        AllTabsChanged = true;
                    }
                    objModule.AllTabs = chkAllTabs.Checked;
                    switch (int.Parse(cboVisibility.SelectedItem.Value))
                    {
                    case 0:

                        objModule.Visibility = VisibilityState.Maximized;
                        break;

                    case 1:

                        objModule.Visibility = VisibilityState.Minimized;
                        break;

                    case 2:

                        objModule.Visibility = VisibilityState.None;
                        break;
                    }
                    objModule.IsDeleted = false;
                    objModule.Header    = txtHeader.Text;
                    objModule.Footer    = txtFooter.Text;
                    if (!String.IsNullOrEmpty(txtStartDate.Text))
                    {
                        objModule.StartDate = Convert.ToDateTime(txtStartDate.Text);
                    }
                    else
                    {
                        objModule.StartDate = Null.NullDate;
                    }
                    if (!String.IsNullOrEmpty(txtEndDate.Text))
                    {
                        objModule.EndDate = Convert.ToDateTime(txtEndDate.Text);
                    }
                    else
                    {
                        objModule.EndDate = Null.NullDate;
                    }
                    objModule.ContainerSrc           = ctlModuleContainer.SkinSrc;
                    objModule.ModulePermissions      = dgPermissions.Permissions;
                    objModule.InheritViewPermissions = chkInheritPermissions.Checked;
                    objModule.DisplayTitle           = chkDisplayTitle.Checked;
                    objModule.DisplayPrint           = chkDisplayPrint.Checked;
                    objModule.DisplaySyndicate       = chkDisplaySyndicate.Checked;
                    objModule.IsDefaultModule        = chkDefault.Checked;
                    objModule.AllModules             = chkAllModules.Checked;
                    objModules.UpdateModule(objModule);

                    //Update Custom Settings
                    if (ctlSpecific != null)
                    {
                        ctlSpecific.UpdateSettings();
                    }

                    //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)
                    {
                        int newTabId = int.Parse(cboTab.SelectedItem.Value);
                        if (TabId != newTabId)
                        {
                            objModules.MoveModule(moduleId, TabId, newTabId, "");
                        }
                    }

                    //'Check if Module is to be Added/Removed from all Tabs
                    if (AllTabsChanged)
                    {
                        ArrayList arrTabs = Globals.GetPortalTabs(PortalSettings.DesktopTabs, false, true);
                        if (chkAllTabs.Checked)
                        {
                            objModules.CopyModule(moduleId, TabId, arrTabs, true);
                        }
                        else
                        {
                            objModules.DeleteAllModules(moduleId, TabId, arrTabs, false, false);
                        }
                    }

                    // Navigate back to admin page
                    Response.Redirect(Globals.NavigateURL(), true);
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// The UpDown_Click server event handler on this page is
        ///   used to move a portal module up or down on a tab's layout pane
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="T:System.Web.UI.ImageClickEventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// </remarks>
        protected void UpDown_Click(object sender, ImageClickEventArgs e)
        {
            var cmd      = ((ImageButton)sender).CommandName;
            var pane     = ((ImageButton)sender).CommandArgument;
            var _listbox = (ListBox)this.Page.FindControl(pane);

            if (_listbox == null)
            {
                _listbox = (ListBox)this.Page.Master.FindControl("Content").FindControl(pane);
            }

            var modules = this.GetModules(pane);

            if (_listbox.SelectedIndex != -1)
            {
                int delta;
                var selection = -1;

                // Determine the delta to apply in the order number for the module
                // within the list.  +3 moves down one item; -3 moves up one item
                if (cmd == "down")
                {
                    delta = 3;
                    if (_listbox.SelectedIndex < _listbox.Items.Count - 1)
                    {
                        selection = _listbox.SelectedIndex + 1;
                    }
                }
                else
                {
                    delta = -3;
                    if (_listbox.SelectedIndex > 0)
                    {
                        selection = _listbox.SelectedIndex - 1;
                    }
                }

                ModuleItem m;
                m = (ModuleItem)modules[_listbox.SelectedIndex];

                if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
                {
                    m.Order += delta;

                    // reorder the modules in the content pane
                    this.OrderModules(modules);

                    // resave the order
                    var admin = new ModulesDB();
                    foreach (ModuleItem item in modules)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, pane);
                    }

                    // Redirect to the same page to pick up changes
                    this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID));
                }
                else
                {
                    this.msgError.Visible = true;
                    return;
                }
            }
        }
Esempio n. 25
0
        private UserControl LoadSkin(string SkinPath)
        {
            UserControl ctlSkin = null;

            try
            {
                if (SkinPath.ToLower().IndexOf(Globals.ApplicationPath.ToLower()) != -1)
                {
                    SkinPath = SkinPath.Remove(0, Globals.ApplicationPath.Length);
                }
                ctlSkin = (UserControl)LoadControl("~" + SkinPath);
                // call databind so that any server logic in the skin is executed
                ctlSkin.DataBind();
            }
            catch (Exception exc)
            {
                if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) || PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString()))
                {
                    // only display the error to administrators
                    SkinError.Text   += "<div style=\"text-align:center\">Could Not Load Skin: " + SkinPath + " Error: " + Server.HtmlEncode(exc.Message) + "</div><br>";
                    SkinError.Visible = true;
                }
            }
            return(ctlSkin);
        }
Esempio n. 26
0
        /// <summary>
        /// The BindData helper method is used to update the tab's
        ///   layout panes with the current configuration information
        /// </summary>
        /// <remarks>
        /// </remarks>
        private void BindData()
        {
            var page = this.PortalSettings.ActivePage;

            // Populate Page Names, etc.
            this.tabName.Text        = page.PageName;
            this.mobilePageName.Text = page.MobilePageName;
            this.showMobile.Checked  = page.ShowMobile;

            // Populate the "ParentPage" Data
            var t     = new PagesDB();
            var items = t.GetPagesParent(this.PortalSettings.PortalID, this.PageID);

            this.parentPage.DataSource = items;
            this.parentPage.DataBind();

            if (this.parentPage.Items.FindByValue(page.ParentPageID.ToString()) != null)
            {
                // parentPage.Items.FindByValue( tab.ParentPageID.ToString() ).Selected = true;
                this.parentPage.SelectedValue = page.ParentPageID.ToString();
            }

            // Translate
            if (this.parentPage.Items.FindByText(" ROOT_LEVEL") != null)
            {
                this.parentPage.Items.FindByText(" ROOT_LEVEL").Text = General.GetString(
                    "ROOT_LEVEL", "Root Level", this.parentPage);
            }

            // Populate checkbox list with all security roles for this portal
            // and "check" the ones already configured for this tab
            var users = new UsersDB();
            var roles = users.GetPortalRoles(this.PortalSettings.PortalAlias);

            // Clear existing items in checkboxlist
            this.authRoles.Items.Clear();

            foreach (var role in roles)
            {
                var item = new ListItem();
                item.Text  = role.Name;
                item.Value = role.Id.ToString();

                if (page.AuthorizedRoles.LastIndexOf(item.Text) > -1)
                {
                    item.Selected = true;
                }

                this.authRoles.Items.Add(item);
            }

            // Populate the "Add Module" Data
            var m       = new ModulesDB();
            var modules = new SortedList <string, string>();
            var drCurrentModuleDefinitions = m.GetCurrentModuleDefinitions(this.PortalSettings.PortalID);
            //if (PortalSecurity.IsInRoles("Admins") || !bool.Parse(drCurrentModuleDefinitions["Admin"].ToString()))
            //{
            var htmlId = "0";

            try {
                while (drCurrentModuleDefinitions.Read())
                {
                    if ((!modules.ContainsKey(drCurrentModuleDefinitions["FriendlyName"].ToString())) &&
                        (PortalSecurity.IsInRoles("Admins") || !bool.Parse(drCurrentModuleDefinitions["Admin"].ToString())))
                    {
                        modules.Add(
                            // moduleType.Items.Add(
                            // new ListItem(drCurrentModuleDefinitions["FriendlyName"].ToString(),
                            // drCurrentModuleDefinitions["ModuleDefID"].ToString()));
                            drCurrentModuleDefinitions["FriendlyName"].ToString(),
                            drCurrentModuleDefinitions["ModuleDefID"].ToString());
                        if (drCurrentModuleDefinitions["FriendlyName"].ToString().Equals("HTML Content"))
                        {
                            htmlId = drCurrentModuleDefinitions["ModuleDefID"].ToString();
                        }
                    }
                }
            }
            finally {
                drCurrentModuleDefinitions.Close();
            }
            //}

            // Dictionary<string, string> actions = ModelServices.GetMVCActionModules();
            // foreach (string key in actions.Keys) {
            // modules.Add(key, actions[key]);
            // }
            this.moduleType.DataSource = modules;
            this.moduleType.DataBind();
            this.moduleType.SelectedValue = htmlId;


            // Now it's the load is by ajax 1/september/2011
            // Populate Top Pane Module Data
            //this.topList = this.GetModules("TopPane");
            //this.topPane.DataBind();

            //// Populate Left Hand Pane Module Data
            //this.leftList = this.GetModules("LeftPane");
            //this.leftPane.DataBind();

            //// Populate Content Pane Module Data
            //this.contentList = this.GetModules("ContentPane");
            //this.contentPane.DataBind();

            //// Populate Right Hand Module Data
            //this.rightList = this.GetModules("RightPane");
            //this.rightPane.DataBind();

            //// Populate Bottom Module Data
            //this.bottomList = this.GetModules("BottomPane");
            //this.bottomPane.DataBind();
        }
        /// <summary>
        /// Override CreateChildControls to create the control tree.
        /// </summary>
        protected override void CreateChildControls()
        {
            // Create an arraylist to fill with
            // the TabItems representing the Tree
            ArrayList crumbs;

            if (HttpContext.Current != null)
            {
                // Obtain PortalSettings from Current Context
                PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

                //Display breadcrumbs if the user has click a tab link  (Without hit the Database again)
                if (portalSettings.ActivePage.PageID > 0)
                {
                    ArrayList authorizedTabs = new ArrayList();
                    int       addedTabs      = 0;
                    for (int i = 0; i < portalSettings.DesktopPages.Count; i++)
                    {
                        PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i];

                        if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                        {
                            authorizedTabs.Add(tab);
                        }
                        addedTabs++;
                    }

                    crumbs = GetBreadCrumbs(portalSettings.ActivePage, authorizedTabs);
                    crumbs.Sort();
                }
                else
                {
                    crumbs = new ArrayList();
                }
            }
            else //design time
            {
                crumbs = new ArrayList();
                crumbs.Add("Item1");
                crumbs.Add("Item2");
                crumbs.Add("Item3");
            }

            if (crumbs.Count > 1)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<div class='");
                sb.Append(CssClass);
                sb.Append("'>");

                int ct = 0;

                // Build the Breadcrumbs and add them to the div
                foreach (PageItem item in crumbs)
                {
                    if (ct > 0)
                    {
                        sb.Append(Separator.ToString());
                    }
                    if (ct != (crumbs.Count - 1))
                    {
                        sb.Append("<a href='");
                        sb.Append(HttpUrlBuilder.BuildUrl(item.ID));
                        sb.Append("'>");
                        sb.Append(item.Name.ToString());
                        sb.Append("</a>");
                    }
                    else
                    {
                        sb.Append(item.Name.ToString());
                    }
                    ct++;
                }
                sb.Append("</div>");
                Text = sb.ToString();
            }
            else
            {
                Visible = false;
            }
        }
 public virtual bool CanViewFolder(FolderInfo folder)
 {
     return(PortalSecurity.IsInRoles(folder.FolderPermissions.ToString(ViewFolderPermissionCode)));
 }
Esempio n. 29
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.selectCulture.SelectedIndexChanged += this.selectCulture_SelectedIndexChanged;
            this.rptLanguages.ItemDataBound         += this.rptLanguages_ItemDataBound;

            try
            {
                var locales = new Dictionary <string, Locale>();
                IEnumerable <ListItem> cultureListItems = DotNetNuke.Services.Localization.Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, this.CurrentCulture, string.Empty, false);
                foreach (Locale loc in LocaleController.Instance.GetLocales(this.PortalSettings.PortalId).Values)
                {
                    string defaultRoles = PortalController.GetPortalSetting(string.Format("DefaultTranslatorRoles-{0}", loc.Code), this.PortalSettings.PortalId, "Administrators");
                    if (!this.PortalSettings.ContentLocalizationEnabled ||
                        (this.LocaleIsAvailable(loc) &&
                         (PortalSecurity.IsInRoles(this.PortalSettings.AdministratorRoleName) || loc.IsPublished || PortalSecurity.IsInRoles(defaultRoles))))
                    {
                        locales.Add(loc.Code, loc);
                        foreach (var cultureItem in cultureListItems)
                        {
                            if (cultureItem.Value == loc.Code)
                            {
                                this.selectCulture.Items.Add(cultureItem);
                            }
                        }
                    }
                }

                if (this.ShowLinks)
                {
                    if (locales.Count > 1)
                    {
                        this.rptLanguages.DataSource = locales.Values;
                        this.rptLanguages.DataBind();
                    }
                    else
                    {
                        this.rptLanguages.Visible = false;
                    }
                }

                if (this.ShowMenu)
                {
                    if (!string.IsNullOrEmpty(this.CssClass))
                    {
                        this.selectCulture.CssClass = this.CssClass;
                    }

                    if (!this.IsPostBack)
                    {
                        // select the default item
                        if (this.CurrentCulture != null)
                        {
                            ListItem item = this.selectCulture.Items.FindByValue(this.CurrentCulture);
                            if (item != null)
                            {
                                this.selectCulture.SelectedIndex = -1;
                                item.Selected = true;
                            }
                        }
                    }

                    // only show language selector if more than one language
                    if (this.selectCulture.Items.Count <= 1)
                    {
                        this.selectCulture.Visible = false;
                    }
                }
                else
                {
                    this.selectCulture.Visible = false;
                }

                this.handleCommonTemplates();
            }
            catch (Exception ex)
            {
                Exceptions.ProcessPageLoadException(ex, this.Request.RawUrl);
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Builds RSS Channel
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// ---Corrected link elment to use prefix 'http://' & current request context.
        /// </remarks>
        /// <history>Sat, 26 Feb 2005 Phil Guerra
        /// </history>
        private string BuildRSS(int PortalId, int TabId, int ModuleId)
        {
            ModuleController objModules = new ModuleController();
            ModuleInfo       objModule;

            StringBuilder sb = new StringBuilder(1024);

            // build header
            sb.Append("<?xml version=\"1.0\" ?>" + "\r\n");
            sb.Append("<rss version=\"2.0\"");
            sb.Append(" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">" + "\r\n");
            // build channel
            sb.Append(WriteElement("channel", 1));
            sb.Append(WriteElement("title", PortalSettings.PortalName, 2));
            // pmg - This line was updated to correct the link item.
            // We are making the assumption that the current context of the
            // request has the desired link to the Portal.  Even though there
            // may be more than 1 portalAlias, this should be correct. If not,
            // we'll have to revisit.
            // sb.Append(WriteElement("link", Request.Url.Host, 2))
            sb.Append(WriteElement("link", Globals.AddHTTP(Globals.GetDomainName(HttpContext.Current.Request)), 2));
            if (!String.IsNullOrEmpty(PortalSettings.Description))
            {
                sb.Append(WriteElement("description", PortalSettings.Description, 2));
            }
            else
            {
                sb.Append(WriteElement("description", PortalSettings.PortalName, 2));
            }
            sb.Append(WriteElement("language", PortalSettings.DefaultLanguage, 2));
            sb.Append(WriteElement("copyright", PortalSettings.FooterText, 2));
            sb.Append(WriteElement("webMaster", PortalSettings.Email, 2));
            // build items
            SearchResultsInfoCollection objResults = SearchDataStoreProvider.Instance().GetSearchItems(PortalId, TabId, ModuleId);
            SearchResultsInfo           objResult;

            foreach (SearchResultsInfo tempLoopVar_objResult in objResults)
            {
                objResult = tempLoopVar_objResult;
                if (PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AuthorizedRoles))
                {
                    if (PortalSettings.ActiveTab.StartDate < DateTime.Now && PortalSettings.ActiveTab.EndDate > DateTime.Now)
                    {
                        objModule = objModules.GetModule(objResult.ModuleId, objResult.TabId);
                        if (objModule.DisplaySyndicate == true && objModule.IsDeleted == false)
                        {
                            if (PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles) == true)
                            {
                                if (Convert.ToDateTime(objModule.StartDate == Null.NullDate ? DateTime.MinValue : objModule.StartDate) < DateTime.Now && Convert.ToDateTime(objModule.EndDate == Null.NullDate ? DateTime.MaxValue : objModule.EndDate) > DateTime.Now)
                                {
                                    sb.Append(BuildItem(objResult, 2));
                                }
                            }
                        }
                    }
                }
            }

            // close document
            sb.Append(WriteElement("/channel", 1));
            sb.Append("</rss>");

            return(sb.ToString());
        }