Ejemplo n.º 1
0
        public static ModuleDefinitionInfo GetModuleDefinitionByFriendlyName(string friendlyName, int desktopModuleID)
        {
            ModuleDefinitionInfo moduleDefinition = null;
            Dictionary <string, ModuleDefinitionInfo> moduleDefinitions = GetModuleDefinitionsByDesktopModuleID(desktopModuleID);

            if (!moduleDefinitions.TryGetValue(friendlyName, out moduleDefinition))
            {
                moduleDefinition = CBO.FillObject <ModuleDefinitionInfo>(dataProvider.GetModuleDefinitionByName(desktopModuleID, friendlyName));
            }
            return(moduleDefinition);
        }
Ejemplo n.º 2
0
        public static ModuleDefinitionInfo GetModuleDefinitionByID(int moduleDefID)
        {
            ModuleDefinitionInfo moduleDefinition = null;
            Dictionary <int, ModuleDefinitionInfo> moduleDefinitions = GetModuleDefinitions();

            if (!moduleDefinitions.TryGetValue(moduleDefID, out moduleDefinition))
            {
                moduleDefinition = CBO.FillObject <ModuleDefinitionInfo>(dataProvider.GetModuleDefinition(moduleDefID));
            }
            return(moduleDefinition);
        }
Ejemplo n.º 3
0
        public static ModuleDefinitionInfo GetModuleDefinitionByFriendlyName(string friendlyName)
        {
            ModuleDefinitionInfo moduleDefinition = null;

            foreach (KeyValuePair <int, ModuleDefinitionInfo> kvp in GetModuleDefinitions())
            {
                if (kvp.Value.FriendlyName == friendlyName)
                {
                    moduleDefinition = kvp.Value;
                    break;
                }
            }
            return(moduleDefinition);
        }
Ejemplo n.º 4
0
        public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache)
        {
            int moduleDefinitionID = moduleDefinition.ModuleDefID;

            if (moduleDefinitionID == Null.NullInteger)
            {
                moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID, moduleDefinition.FriendlyName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
            }
            else
            {
                dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
            }
            if (saveChildren)
            {
                foreach (KeyValuePair <string, PermissionInfo> kvp in moduleDefinition.Permissions)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;
                    PermissionController permissionController = new PermissionController();
                    ArrayList            permissions          = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey);
                    if (permissions != null && permissions.Count == 1)
                    {
                        PermissionInfo permission = (PermissionInfo)permissions[0];
                        kvp.Value.PermissionID = permission.PermissionID;
                        permissionController.UpdatePermission(kvp.Value);
                    }
                    else
                    {
                        permissionController.AddPermission(kvp.Value);
                    }
                }
                foreach (KeyValuePair <string, ModuleControlInfo> kvp in moduleDefinition.ModuleControls)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;
                    ModuleControlInfo moduleControl = ModuleControlController.GetModuleControlByControlKey(kvp.Value.ControlKey, kvp.Value.ModuleDefID);
                    if (moduleControl != null)
                    {
                        kvp.Value.ModuleControlID = moduleControl.ModuleControlID;
                    }
                    ModuleControlController.SaveModuleControl(kvp.Value, clearCache);
                }
            }
            if (clearCache)
            {
                DataCache.ClearHostCache(true);
            }
            return(moduleDefinitionID);
        }
 public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache)
 {
     int moduleDefinitionID = moduleDefinition.ModuleDefID;
     if (moduleDefinitionID == Null.NullInteger)
     {
         moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID, moduleDefinition.FriendlyName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
     }
     else
     {
         dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
     }
     if (saveChildren)
     {
         foreach (KeyValuePair<string, PermissionInfo> kvp in moduleDefinition.Permissions)
         {
             kvp.Value.ModuleDefID = moduleDefinitionID;
             PermissionController permissionController = new PermissionController();
             ArrayList permissions = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey);
             if (permissions != null && permissions.Count == 1)
             {
                 PermissionInfo permission = (PermissionInfo)permissions[0];
                 kvp.Value.PermissionID = permission.PermissionID;
                 permissionController.UpdatePermission(kvp.Value);
             }
             else
             {
                 permissionController.AddPermission(kvp.Value);
             }
         }
         foreach (KeyValuePair<string, ModuleControlInfo> kvp in moduleDefinition.ModuleControls)
         {
             kvp.Value.ModuleDefID = moduleDefinitionID;
             ModuleControlInfo moduleControl = ModuleControlController.GetModuleControlByControlKey(kvp.Value.ControlKey, kvp.Value.ModuleDefID);
             if (moduleControl != null)
             {
                 kvp.Value.ModuleControlID = moduleControl.ModuleControlID;
             }
             ModuleControlController.SaveModuleControl(kvp.Value, clearCache);
         }
     }
     if (clearCache)
     {
         DataCache.ClearHostCache(true);
     }
     return moduleDefinitionID;
 }
Ejemplo n.º 6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddModuleDefinition adds a new Core Module Definition to the system
        /// </summary>
        /// <remarks>
        ///	This overload allows the caller to determine whether the module has a controller
        /// class
        /// </remarks>
        ///	<param name="DesktopModuleName">The Friendly Name of the Module to Add</param>
        ///	<param name="Description">Description of the Module</param>
        ///	<param name="ModuleDefinitionName">The Module Definition Name</param>
        ///	<param name="Premium">A flag representing whether the module is a Premium module</param>
        ///	<param name="Admin">A flag representing whether the module is an Admin module</param>
        ///	<returns>The Module Definition Id of the new Module</returns>
        /// <history>
        /// [cnurse]	10/14/2004	documented
        /// [cnurse] 11/11/2004 removed addition of Module Control (now in AddMOduleControl)
        /// </history>
        /// -----------------------------------------------------------------------------
        private static int AddModuleDefinition(string DesktopModuleName, string Description, string ModuleDefinitionName, string BusinessControllerClass, bool IsPortable, bool Premium, bool Admin)
        {
            // check if desktop module exists
            DesktopModuleInfo objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName(DesktopModuleName, Null.NullInteger);
            if (objDesktopModule == null)
            {
                PackageInfo package = new PackageInfo();
                package.Description = Description;
                package.FriendlyName = DesktopModuleName;
                package.Name = string.Concat("DotNetNuke.", DesktopModuleName);
                package.PackageType = "Module";
                package.Owner = "DotNetNuke";
                package.Organization = "DotNetNuke Corporation";
                package.Url = "www.dotnetnuke.com";
                package.Email = "*****@*****.**";
                if (DesktopModuleName == "Extensions" || DesktopModuleName == "Skin Designer" || DesktopModuleName == "Dashboard")
                {
                    package.IsSystemPackage = true;
                }
                package.Version = new System.Version(1, 0, 0);

                package.PackageID = PackageController.AddPackage(package, false);

                string moduleName = DesktopModuleName.Replace(" ", "");
                objDesktopModule = new DesktopModuleInfo();
                objDesktopModule.DesktopModuleID = Null.NullInteger;
                objDesktopModule.PackageID = package.PackageID;
                objDesktopModule.FriendlyName = DesktopModuleName;
                objDesktopModule.FolderName = "Admin/" + moduleName;
                objDesktopModule.ModuleName = moduleName;
                objDesktopModule.Description = Description;
                objDesktopModule.Version = "01.00.00";
                objDesktopModule.BusinessControllerClass = BusinessControllerClass;
                objDesktopModule.IsPortable = IsPortable;
                objDesktopModule.SupportedFeatures = 0;
                if ((IsPortable))
                {
                    objDesktopModule.SupportedFeatures = 1;
                }
                objDesktopModule.IsPremium = Premium;
                objDesktopModule.IsAdmin = Admin;

                objDesktopModule.DesktopModuleID = DesktopModuleController.SaveDesktopModule(objDesktopModule, false, false);

                if (!Premium)
                {
                    DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID);
                }
            }

            // check if module definition exists
            ModuleDefinitionInfo objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefinitionName, objDesktopModule.DesktopModuleID);
            if (objModuleDefinition == null)
            {
                objModuleDefinition = new ModuleDefinitionInfo();

                objModuleDefinition.ModuleDefID = Null.NullInteger;
                objModuleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID;
                objModuleDefinition.FriendlyName = ModuleDefinitionName;

                objModuleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(objModuleDefinition, false, false);
            }

            return objModuleDefinition.ModuleDefID;
        }
 private void ReadModuleDefinitions(XmlReader reader)
 {
     reader.ReadStartElement("moduleDefinitions");
     do
     {
         reader.ReadStartElement("moduleDefinition");
         ModuleDefinitionInfo moduleDefinition = new ModuleDefinitionInfo();
         moduleDefinition.ReadXml(reader);
         ModuleDefinitions.Add(moduleDefinition.FriendlyName, moduleDefinition);
     } while (reader.ReadToNextSibling("moduleDefinition"));
 }
Ejemplo n.º 8
0
 public void UpdateModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     SaveModuleDefinition(objModuleDefinition, false, true);
 }
Ejemplo n.º 9
0
 public void DeleteModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     DeleteModuleDefinition(objModuleDefinition.ModuleDefID);
 }
Ejemplo n.º 10
0
 public int AddModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     return(SaveModuleDefinition(objModuleDefinition, false, true));
 }
 private static void ProcessControls(XPathNavigator controlNav, string moduleFolder, ModuleDefinitionInfo definition)
 {
     ModuleControlInfo moduleControl = new ModuleControlInfo();
     moduleControl.ControlKey = Util.ReadElement(controlNav, "key");
     moduleControl.ControlTitle = Util.ReadElement(controlNav, "title");
     string ControlSrc = Util.ReadElement(controlNav, "src");
     if (!(ControlSrc.ToLower().StartsWith("desktopmodules") || !ControlSrc.ToLower().EndsWith(".ascx")))
     {
         ControlSrc = Path.Combine("DesktopModules", Path.Combine(moduleFolder, ControlSrc));
     }
     ControlSrc = ControlSrc.Replace('\\', '/');
     moduleControl.ControlSrc = ControlSrc;
     moduleControl.IconFile = Util.ReadElement(controlNav, "iconfile");
     string controlType = Util.ReadElement(controlNav, "type");
     if (!string.IsNullOrEmpty(controlType))
     {
         try
         {
             moduleControl.ControlType = (SecurityAccessLevel)TypeDescriptor.GetConverter(typeof(SecurityAccessLevel)).ConvertFromString(controlType);
         }
         catch (Exception ex)
         {
             throw new Exception(Util.EXCEPTION_Type + ex.ToString());
         }
     }
     string viewOrder = Util.ReadElement(controlNav, "vieworder");
     if (!string.IsNullOrEmpty(viewOrder))
     {
         moduleControl.ViewOrder = int.Parse(viewOrder);
     }
     moduleControl.HelpURL = Util.ReadElement(controlNav, "helpurl");
     string supportsPartialRendering = Util.ReadElement(controlNav, "supportspartialrendering");
     if (!string.IsNullOrEmpty(supportsPartialRendering))
     {
         moduleControl.SupportsPartialRendering = bool.Parse(supportsPartialRendering);
     }
     definition.ModuleControls[moduleControl.ControlKey] = moduleControl;
 }
 private void ProcessModules(XPathNavigator moduleNav, string moduleFolder)
 {
     ModuleDefinitionInfo definition = new ModuleDefinitionInfo();
     definition.FriendlyName = Util.ReadElement(moduleNav, "friendlyname");
     string cacheTime = Util.ReadElement(moduleNav, "cachetime");
     if (!string.IsNullOrEmpty(cacheTime))
     {
         definition.DefaultCacheTime = int.Parse(cacheTime);
     }
     foreach (XPathNavigator controlNav in moduleNav.Select("controls/control"))
     {
         ProcessControls(controlNav, moduleFolder, definition);
     }
     DesktopModule.ModuleDefinitions[definition.FriendlyName] = definition;
 }
 public void UpdateModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     SaveModuleDefinition(objModuleDefinition, false, true);
 }
 public void DeleteModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     DeleteModuleDefinition(objModuleDefinition.ModuleDefID);
 }
 public int AddModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     return SaveModuleDefinition(objModuleDefinition, false, true);
 }