Exemple #1
0
    protected void fillList()
    {
        list = new List <DesktopModuleInfo>();
        DesktopModuleController dmc = new DesktopModuleController();

        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("DesktopModules/AIS/Installer/Modules.xml") /*Modules"C:\\inetpub\\wwwroot\\DNN\\DesktopModules\\AIS\\Installer\\Modules.xml"*/);
        while (reader.Read())
        {
            reader.MoveToContent();
            if (reader.Name == "module")
            {
                if (reader.HasAttributes)
                {
                    DesktopModuleInfo dmi = dmc.GetDesktopModuleByName(reader.GetAttribute("friendlyName"));
                    //We check if the module is already activated. If it is, there's no need to reinstall it
                    if (dmi != null)
                    {
                        if (!IsInPage(dmi))
                        {
                            list.Add(dmi);
                        }
                    }
                }
            }
        }
    }
        public static List <ListItem> GetModuleList(string ModuleName)
        {
            List <ListItem> lst                        = new List <ListItem>();
            PortalSettings  portalSettings             = PortalController.GetCurrentPortalSettings();
            List <TabInfo>  objTabs                    = TabController.GetPortalTabs(portalSettings.PortalId, -1, true, true);
            var             objTabController           = new TabController();
            var             objDesktopModuleController = new DesktopModuleController();
            var             objDesktopModuleInfo       = objDesktopModuleController.GetDesktopModuleByModuleName(ModuleName);

            if (objDesktopModuleInfo == null)
            {
                objDesktopModuleInfo = objDesktopModuleController.GetDesktopModuleByName(ModuleName);
                if (objDesktopModuleInfo == null)
                {
                    return(lst);
                }
            }
            foreach (TabInfo objTab in objTabs.Where(tab => !tab.IsDeleted))
            {
                ModuleController objModules = new ModuleController();
                foreach (KeyValuePair <int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID))
                {
                    ModuleInfo objModule = pair.Value;
                    if (objModule.IsDeleted)
                    {
                        continue;
                    }
                    if (objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }
                    string  strPath        = objTab.TabName;
                    TabInfo objTabSelected = objTab;
                    while (objTabSelected.ParentId != Null.NullInteger)
                    {
                        objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false);
                        if (objTabSelected == null)
                        {
                            break;
                        }
                        strPath = string.Format("{0} -> {1}", objTabSelected.TabName, strPath);
                    }
                    var objListItem = new ListItem
                    {
                        Value = objModule.ModuleID.ToString(),
                        Text  = string.Format("{0} -> {1}", strPath, objModule.ModuleTitle)
                    };
                    lst.Add(objListItem);
                }
            }
            return(lst);
        }
Exemple #3
0
        private TabInfo CreateSubTab(string tabName, int departmentId, string settingsName = "department", int?parentTabID = null)
        {
            //Create Tab
            TabController tabController = new TabController();

            TabInfo tab = new TabInfo();

            tab.PortalID = PortalId;
            tab.TabName  = tabName;
            tab.Title    = tabName;

            //works for include in menu option. if true, will be shown in menus, else will not be shown, we have to redirect internally
            tab.IsVisible   = true;
            tab.DisableLink = false;

            //if this tab has any parents provide parent tab id, so that it will be shown in parent tab menus sub menu list, else is NULL
            //and will be in main menu list
            if (parentTabID == null)
            {
                tab.ParentId = TabId;
            }
            else
            {
                tab.ParentId = parentTabID.Value;
            }
            tab.IsDeleted    = false;
            tab.Url          = "";
            tab.IsSuperTab   = false;                            //if true, it has no parents, else false
            tab.SkinSrc      = "[G]Skins/Artfolio001/page.ascx"; //provide skin src, else will take default skin
            tab.ContainerSrc = "[G]Containers/Artfolio001/Block.ascx";
            int tabId = tabController.AddTab(tab, true);         //true to load defalut modules

            //Set Tab Permission
            TabPermissionController objTPC = new TabPermissionController();

            TabPermissionInfo tpi = new TabPermissionInfo();

            tpi.TabID          = tabId;
            tpi.PermissionID   = 3; //for view
            tpi.PermissionKey  = "VIEW";
            tpi.PermissionName = "View Tab";
            tpi.AllowAccess    = true;
            tpi.RoleID         = 0; //Role ID of administrator
            objTPC.AddTabPermission(tpi);

            TabPermissionInfo tpi1 = new TabPermissionInfo();

            tpi1.TabID          = tabId;
            tpi1.PermissionID   = 4; //for edit
            tpi1.PermissionKey  = "EDIT";
            tpi1.PermissionName = "Edit Tab";
            tpi1.AllowAccess    = true;
            tpi1.RoleID         = 0; //Role ID of administrator
            objTPC.AddTabPermission(tpi1);

            TabPermissionInfo tpi4 = new TabPermissionInfo();

            tpi4.TabID          = tabId;
            tpi4.PermissionID   = 3;
            tpi4.PermissionKey  = "VIEW";
            tpi4.PermissionName = "View Tab";
            tpi4.AllowAccess    = true;
            tpi4.RoleID         = -1; //All users
            objTPC.AddTabPermission(tpi4);

            //Add Module
            DesktopModuleController objDMC            = new DesktopModuleController();
            DesktopModuleInfo       desktopModuleInfo = objDMC.GetDesktopModuleByName("Clothes");

            ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo();
            ModuleInfo           moduleInfo           = new ModuleInfo();

            moduleInfo.PortalID                     = PortalId;
            moduleInfo.TabID                        = tabId;
            moduleInfo.ModuleOrder                  = 1;
            moduleInfo.ModuleTitle                  = "Clothes";
            moduleInfo.PaneName                     = "Clothes";
            moduleInfo.ModuleDefID                  = 160;
            moduleInfo.CacheTime                    = moduleDefinitionInfo.DefaultCacheTime; //Default Cache Time is 0
            moduleInfo.InheritViewPermissions       = true;                                  //Inherit View Permissions from Tab
            moduleInfo.AllTabs                      = false;
            moduleInfo.ModuleSettings[settingsName] = departmentId;

            ModuleController moduleController = new ModuleController();
            int moduleId = moduleController.AddModule(moduleInfo);

            //Set Module Permission
            ModulePermissionController objMPC = new ModulePermissionController();

            ModulePermissionInfo mpi1 = new ModulePermissionInfo();

            mpi1.ModuleID     = moduleId;
            mpi1.PermissionID = 1; //View Permission
            mpi1.AllowAccess  = true;
            mpi1.RoleID       = 0; //Role ID of Administrator
            objMPC.AddModulePermission(mpi1);

            ModulePermissionInfo mpi2 = new ModulePermissionInfo();

            mpi2.ModuleID     = moduleId;
            mpi2.PermissionID = 2; //Edit Permission
            mpi2.AllowAccess  = true;
            mpi2.RoleID       = 0; //Role ID of Administrator
            objMPC.AddModulePermission(mpi2);

            ModulePermissionInfo mpi5 = new ModulePermissionInfo();

            mpi5.ModuleID     = moduleId;
            mpi5.PermissionID = 1; //View Permission
            mpi5.AllowAccess  = true;
            mpi5.RoleID       = 1; //Role ID of Registered User
            objMPC.AddModulePermission(mpi5);
            return(tab);
        }
        /// <summary>
        /// Fills the module list.
        /// </summary>
        private void FillModuleList()
        {
            PortalSettings portalSettings = PortalController.GetCurrentPortalSettings();

            List <TabInfo> objTabs = TabController.GetPortalTabs(portalSettings.PortalId, -1, true, true);

            var objTabController = new TabController();

            var objDesktopModuleController = new DesktopModuleController();
            var objDesktopModuleInfo       = objDesktopModuleController.GetDesktopModuleByModuleName("DnnForge - NewsArticles");

            if (objDesktopModuleInfo == null)
            {
                objDesktopModuleInfo = objDesktopModuleController.GetDesktopModuleByName("DnnForge - NewsArticles");

                if (objDesktopModuleInfo == null)
                {
                    return;
                }
            }

            foreach (TabInfo objTab in objTabs.Where(tab => !tab.IsDeleted))
            {
                ModuleController objModules = new ModuleController();

                foreach (KeyValuePair <int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID))
                {
                    ModuleInfo objModule = pair.Value;

                    if (objModule.IsDeleted)
                    {
                        continue;
                    }

                    if (objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }

                    string  strPath        = objTab.TabName;
                    TabInfo objTabSelected = objTab;

                    while (objTabSelected.ParentId != Null.NullInteger)
                    {
                        objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false);
                        if (objTabSelected == null)
                        {
                            break;
                        }

                        strPath = string.Format("{0} -> {1}", objTabSelected.TabName, strPath);
                    }

                    var objListItem = new ListItem
                    {
                        Value = string.Format("{0}-{1}", objModule.TabID, objModule.ModuleID),
                        Text  = string.Format("{2}: {0} -> {3}: {1}", strPath, objModule.ModuleTitle, Localization.GetString("Page.Text", this.ResXFile, this.LangCode), Localization.GetString("ModuleInstance.Text", this.ResXFile, this.LangCode))
                    };

                    ModuleListDropDown.Items.Add(objListItem);
                }
            }
        }
    protected void btn_creation_Click(object sender, EventArgs e)
    {
        try
        {
            String         pageName = ddl_month.SelectedValue + " " + ddl_year.SelectedValue;
            String         url      = ddl_month.SelectedValue + "" + ddl_year.SelectedValue;
            RoleController rc       = new RoleController();
            RoleInfo       ri       = rc.GetRoleByName(PortalId, role);

            List <TabPermissionInfo> permissions = new List <TabPermissionInfo>();
            foreach (PermissionInfo p in PermissionController.GetPermissionsByTab())
            {
                if (p.PermissionKey == "VIEW")
                {
                    TabPermissionInfo tpi = new TabPermissionInfo();
                    tpi.PermissionID   = p.PermissionID;
                    tpi.PermissionKey  = p.PermissionKey;
                    tpi.PermissionName = p.PermissionName;
                    tpi.AllowAccess    = true;;
                    tpi.RoleID         = ri.RoleID;
                    permissions.Add(tpi);
                }
                if (p.PermissionKey == "EDIT")
                {
                    TabPermissionInfo tpi = new TabPermissionInfo();
                    tpi.PermissionID   = p.PermissionID;
                    tpi.PermissionKey  = p.PermissionKey;
                    tpi.PermissionName = p.PermissionName;
                    tpi.AllowAccess    = true;;
                    tpi.RoleID         = ri.RoleID;
                    permissions.Add(tpi);
                }
            }

            if (!createPage(pageName, permissions, false, false, "Courrier du District"))
            {
                pnl_page.Visible           = false;
                pnl_error.Visible          = true;
                hlk_pageExists.NavigateUrl = redirect + url + ".aspx";
            }
            else if (!createPage(pageName + "_article", permissions, false, false, pageName))
            {
                pnl_page.Visible           = false;
                pnl_error.Visible          = true;
                hlk_pageExists.NavigateUrl = redirect + url + "_article.aspx";
            }
            else
            {
                TabController           TC            = new TabController();
                TabInfo                 tabPrincipale = TC.GetTabByName(pageName, PortalId);
                DesktopModuleController DMC           = new DesktopModuleController();
                DesktopModuleInfo       dmi           = DMC.GetDesktopModuleByModuleName("AIS.NewsPanel");
                dmi.ContentTitle = "courrier du district - " + pageName;
                TabInfo           tabArticle = TC.GetTabByName(pageName + "_article", PortalId);
                DesktopModuleInfo dmiArticle = DMC.GetDesktopModuleByModuleName("AIS.NewsArticle");

                Dictionary <String, String> settingsMiniNews = new Dictionary <string, string>();
                Dictionary <String, String> settings         = new Dictionary <string, string>();
                Dictionary <String, String> settings1Tiers   = new Dictionary <string, string>();
                settings.Add("tabid", pageName + "_article");
                settings1Tiers.Add("tabid", pageName + "_article");
                settings.Add("category", "courrierdistrict");
                settings1Tiers.Add("category", "courrierdistrict");
                settings.Add("tags_included", (ddl_month.SelectedIndex + 1 < 10 ? ddl_year.SelectedValue + "0" + (ddl_month.SelectedIndex + 1) : ddl_year.SelectedValue + (ddl_month.SelectedIndex + 1)));
                settings1Tiers.Add("tags_included", (ddl_month.SelectedIndex + 1 < 10 ? ddl_year.SelectedValue + "0" + (ddl_month.SelectedIndex + 1) : ddl_year.SelectedValue + (ddl_month.SelectedIndex + 1)));
                settingsMiniNews.Add("style", style);
                settings1Tiers.Add("style", style);
                settingsMiniNews.Add("path", path);
                settings.Add("path", path);
                settings1Tiers.Add("path", path);
                settingsMiniNews.Add("impress", impress);



                DesktopModuleInfo dmiHtml = DMC.GetDesktopModuleByName("HTML");
                if (dmiHtml == null)
                {
                    throw new Exception("HTML ");
                }

                dmiHtml.ContentTitle = "Edito";
                AddModuleToTab(tabPrincipale, dmi, paneName: "Zero2Tiers", settings: settings);
                AddModuleToTab(tabArticle, dmiArticle, paneName: "Zero2Tiers", settings: settingsMiniNews);
                AddModuleToTab(tabArticle, dmi, paneName: "Zero1Tiers", settings: settings1Tiers);
                AddModuleToTab(tabPrincipale, dmiHtml, paneName: "Zero1Tiers");


                pnl_success.Visible = true;
                pnl_page.Visible    = false;
                String[] splits = pageName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                pageName = splits[0] + splits[1];
                Response.Redirect(redirect + pageName + ".aspx");
            }
        }
        catch (Exception ee)
        {
            Functions.Error(ee);
        }
    }