示例#1
0
        public int AddModuleToPage(TabInfo t, ModuleType type)
        {
            string DesktopModuleFriendlyName="";
            string ModuleDefFriendlyName="";

            ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo();
            ModuleInfo moduleInfo = new ModuleInfo();
            moduleInfo.PortalID = t.PortalID;
            moduleInfo.TabID = t.TabID;
            moduleInfo.ModuleOrder = 1;
            moduleInfo.ModuleTitle = "";
            moduleInfo.DisplayPrint = false;
            moduleInfo.IsShareable = true;
            moduleInfo.IsShareableViewOnly = true;

            switch (type)
            {
                case ModuleType.DisplayPlugg:
                    moduleInfo.PaneName = "RowTwo_Grid8_Pane";
                    DesktopModuleFriendlyName = "DisplayPlugg";
                    ModuleDefFriendlyName = "DisplayPlugg";
                    break;
                case ModuleType.DisplayCourse:
                    moduleInfo.PaneName = "RowTwo_Grid8_Pane";
                    DesktopModuleFriendlyName = "DisplayCourse";
                    ModuleDefFriendlyName = "DisplayCourse";
                    break;
                case ModuleType.CourseMenu:
                    moduleInfo.PaneName = "RowTwo_Grid4_Pane";
                    DesktopModuleFriendlyName = "CourseMenu";
                    ModuleDefFriendlyName = "CourseMenu";
                    break;
                case ModuleType.Rating:
                    moduleInfo.PaneName = "RowTwo_Grid4_Pane";
                    DesktopModuleFriendlyName = "DNNCentric RnC";
                    ModuleDefFriendlyName = "DNNCentric.RatingAndComments";
                    break;
                case ModuleType.Comments:
                    moduleInfo.PaneName = "RowTwo_Grid8_Pane";
                    DesktopModuleFriendlyName = "DNNCentric RnC";
                    ModuleDefFriendlyName = "DNNCentric.RatingAndComments";
                    break;
                case ModuleType.DisplayPluggeTitle:
                    moduleInfo.PaneName = "RowTwo_Grid4_Pane";
                    DesktopModuleFriendlyName = "DisplayPluggeTitle";
                    ModuleDefFriendlyName = "DisplayPluggeTitle";
                    break;

               }

            DesktopModuleInfo myModule = null;
            foreach (KeyValuePair<int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(t.PortalID))
            {
                DesktopModuleInfo mod = kvp.Value;
                if (mod != null)
                    if (mod.FriendlyName == DesktopModuleFriendlyName)
                    {
                        myModule = mod;
                        break;
                    }
            }

            int moduleId=0;
            if (myModule != null)
            {
                var mc = new ModuleDefinitionController();
                var mInfo = new ModuleDefinitionInfo();
                mInfo = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefFriendlyName,
                    myModule.DesktopModuleID);
                moduleInfo.ModuleDefID = mInfo.ModuleDefID;
                moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime;//Default Cache Time is 0
                moduleInfo.InheritViewPermissions = true;  //Inherit View Permissions from Tab
                moduleInfo.AllTabs = false;
                moduleInfo.Alignment = "Top";

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

            DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(t.TabID);
            DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(t.PortalID);
            DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(t.PortalID, false);

            //Add settings for RnC
            ModuleController m = new ModuleController();
            if (type == ModuleType.Rating)
            {
                AddModuleSettingsRnCCommon(moduleId);
                m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
                m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyRatings");
                m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "357");
            }
            if (type == ModuleType.Comments)
            {
                AddModuleSettingsRnCCommon(moduleId);
                m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
                m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyComments");
                m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "744");
            }

            if (type == ModuleType.Rating || type == ModuleType.Comments)
            {
                RnCController c = new RnCController();
                DCC_PRC_CommentObject myCO = new DCC_PRC_CommentObject();
                myCO.CommentObject = "tabid:" + t.TabID;
                myCO.CommentObjectViewCount = 0;
                myCO.PortalID = t.PortalID;
                c.CreateCommentObject(myCO);
            }
            return moduleId;
        }
示例#2
0
        public int AddModuleToPage(TabInfo t, ModuleType type)
        {
            string DesktopModuleFriendlyName = "";
            string ModuleDefFriendlyName     = "";

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

            moduleInfo.PortalID            = t.PortalID;
            moduleInfo.TabID               = t.TabID;
            moduleInfo.ModuleOrder         = 1;
            moduleInfo.ModuleTitle         = "";
            moduleInfo.DisplayPrint        = false;
            moduleInfo.IsShareable         = true;
            moduleInfo.IsShareableViewOnly = true;

            switch (type)
            {
            case ModuleType.DisplayPlugg:
                moduleInfo.PaneName       = "RowTwo_Grid8_Pane";
                DesktopModuleFriendlyName = "DisplayPlugg";
                ModuleDefFriendlyName     = "DisplayPlugg";
                break;

            case ModuleType.DisplayCourse:
                moduleInfo.PaneName       = "RowTwo_Grid8_Pane";
                DesktopModuleFriendlyName = "DisplayCourse";
                ModuleDefFriendlyName     = "DisplayCourse";
                break;

            case ModuleType.CourseMenu:
                moduleInfo.PaneName       = "RowTwo_Grid4_Pane";
                DesktopModuleFriendlyName = "CourseMenu";
                ModuleDefFriendlyName     = "CourseMenu";
                break;

            case ModuleType.Rating:
                moduleInfo.PaneName       = "RowTwo_Grid4_Pane";
                DesktopModuleFriendlyName = "DNNCentric RnC";
                ModuleDefFriendlyName     = "DNNCentric.RatingAndComments";
                break;

            case ModuleType.Comments:
                moduleInfo.PaneName       = "RowTwo_Grid8_Pane";
                DesktopModuleFriendlyName = "DNNCentric RnC";
                ModuleDefFriendlyName     = "DNNCentric.RatingAndComments";
                break;

            case ModuleType.DisplayPluggeTitle:
                moduleInfo.PaneName       = "RowTwo_Grid4_Pane";
                DesktopModuleFriendlyName = "DisplayPluggeTitle";
                ModuleDefFriendlyName     = "DisplayPluggeTitle";
                break;
            }

            DesktopModuleInfo myModule = null;

            foreach (KeyValuePair <int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(t.PortalID))
            {
                DesktopModuleInfo mod = kvp.Value;
                if (mod != null)
                {
                    if (mod.FriendlyName == DesktopModuleFriendlyName)
                    {
                        myModule = mod;
                        break;
                    }
                }
            }

            int moduleId = 0;

            if (myModule != null)
            {
                var mc    = new ModuleDefinitionController();
                var mInfo = new ModuleDefinitionInfo();
                mInfo = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefFriendlyName,
                                                                                     myModule.DesktopModuleID);
                moduleInfo.ModuleDefID            = mInfo.ModuleDefID;
                moduleInfo.CacheTime              = moduleDefinitionInfo.DefaultCacheTime; //Default Cache Time is 0
                moduleInfo.InheritViewPermissions = true;                                  //Inherit View Permissions from Tab
                moduleInfo.AllTabs   = false;
                moduleInfo.Alignment = "Top";

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

            DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(t.TabID);
            DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(t.PortalID);
            DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(t.PortalID, false);

            //Add settings for RnC
            ModuleController m = new ModuleController();

            if (type == ModuleType.Rating)
            {
                AddModuleSettingsRnCCommon(moduleId);
                m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
                m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyRatings");
                m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "357");
            }
            if (type == ModuleType.Comments)
            {
                AddModuleSettingsRnCCommon(moduleId);
                m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
                m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyComments");
                m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "744");
            }

            if (type == ModuleType.Rating || type == ModuleType.Comments)
            {
                RnCController         c    = new RnCController();
                DCC_PRC_CommentObject myCO = new DCC_PRC_CommentObject();
                myCO.CommentObject          = "tabid:" + t.TabID;
                myCO.CommentObjectViewCount = 0;
                myCO.PortalID = t.PortalID;
                c.CreateCommentObject(myCO);
            }
            return(moduleId);
        }