private static Dictionary<int, DesktopModulePermissionCollection> FillDesktopModulePermissionDictionary(IDataReader dr)
 {
     Dictionary<int, DesktopModulePermissionCollection> dic = new Dictionary<int, DesktopModulePermissionCollection>();
     try
     {
         DesktopModulePermissionInfo obj;
         while (dr.Read())
         {
             obj = CBO.FillObject<DesktopModulePermissionInfo>(dr, false);
             if (dic.ContainsKey(obj.PortalDesktopModuleID))
             {
                 dic[obj.PortalDesktopModuleID].Add(obj);
             }
             else
             {
                 DesktopModulePermissionCollection collection = new DesktopModulePermissionCollection();
                 collection.Add(obj);
                 dic.Add(obj.PortalDesktopModuleID, collection);
             }
         }
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
     finally
     {
         CBO.CloseDataReader(dr, true);
     }
     return dic;
 }
Beispiel #2
0
 public void AddRange(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     foreach (DesktopModulePermissionInfo permission in DesktopModulePermissions)
     {
         Add(permission);
     }
 }
 public void AddRange(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     foreach (DesktopModulePermissionInfo permission in DesktopModulePermissions)
     {
         Add(permission);
     }
 }
        private static Dictionary <int, DesktopModulePermissionCollection> FillDesktopModulePermissionDictionary(IDataReader dr)
        {
            Dictionary <int, DesktopModulePermissionCollection> dic = new Dictionary <int, DesktopModulePermissionCollection>();

            try
            {
                DesktopModulePermissionInfo obj;
                while (dr.Read())
                {
                    obj = CBO.FillObject <DesktopModulePermissionInfo>(dr, false);
                    if (dic.ContainsKey(obj.PortalDesktopModuleID))
                    {
                        dic[obj.PortalDesktopModuleID].Add(obj);
                    }
                    else
                    {
                        DesktopModulePermissionCollection collection = new DesktopModulePermissionCollection();
                        collection.Add(obj);
                        dic.Add(obj.PortalDesktopModuleID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                CBO.CloseDataReader(dr, true);
            }
            return(dic);
        }
        public static DesktopModulePermissionCollection GetDesktopModulePermissions(int portalDesktopModuleID)
        {
            bool bFound = false;
            Dictionary <int, DesktopModulePermissionCollection> dicDesktopModulePermissions = GetDesktopModulePermissions();
            DesktopModulePermissionCollection DesktopModulePermissions = null;

            bFound = dicDesktopModulePermissions.TryGetValue(portalDesktopModuleID, out DesktopModulePermissions);
            if (!bFound)
            {
                DesktopModulePermissions = new DesktopModulePermissionCollection(CBO.FillCollection(provider.GetDesktopModulePermissionsByPortalDesktopModuleID(portalDesktopModuleID), typeof(DesktopModulePermissionInfo)), portalDesktopModuleID);
            }
            return(DesktopModulePermissions);
        }
 public static int AddDesktopModuleToPortal(int portalID, DesktopModuleInfo desktopModule, DesktopModulePermissionCollection permissions, bool clearCache)
 {
     int portalDesktopModuleID = AddDesktopModuleToPortal(portalID, desktopModule.DesktopModuleID, false, clearCache);
     if (portalDesktopModuleID > Null.NullInteger)
     {
         DesktopModulePermissionController.DeleteDesktopModulePermissionsByPortalDesktopModuleID(portalDesktopModuleID);
         foreach (DesktopModulePermissionInfo permission in permissions)
         {
             permission.PortalDesktopModuleID = portalDesktopModuleID;
             DesktopModulePermissionController.AddDesktopModulePermission(permission);
         }
     }
     return portalDesktopModuleID;
 }
Beispiel #7
0
 public bool CompareTo(DesktopModulePermissionCollection objDesktopModulePermissionCollection)
 {
     if (objDesktopModulePermissionCollection.Count != this.Count)
     {
         return(false);
     }
     InnerList.Sort(new CompareDesktopModulePermissions());
     objDesktopModulePermissionCollection.InnerList.Sort(new CompareDesktopModulePermissions());
     for (int i = 0; i <= this.Count - 1; i++)
     {
         if (objDesktopModulePermissionCollection[i].DesktopModulePermissionID != this[i].DesktopModulePermissionID || objDesktopModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return(false);
         }
     }
     return(true);
 }
 public bool CompareTo(DesktopModulePermissionCollection objDesktopModulePermissionCollection)
 {
     if (objDesktopModulePermissionCollection.Count != this.Count)
     {
         return false;
     }
     InnerList.Sort(new CompareDesktopModulePermissions());
     objDesktopModulePermissionCollection.InnerList.Sort(new CompareDesktopModulePermissions());
     for (int i = 0; i <= this.Count - 1; i++)
     {
         if (objDesktopModulePermissionCollection[i].DesktopModulePermissionID != this[i].DesktopModulePermissionID || objDesktopModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return false;
         }
     }
     return true;
 }
 public static DesktopModulePermissionCollection GetDesktopModulePermissions(int portalDesktopModuleID)
 {
     bool bFound = false;
     Dictionary<int, DesktopModulePermissionCollection> dicDesktopModulePermissions = GetDesktopModulePermissions();
     DesktopModulePermissionCollection DesktopModulePermissions = null;
     bFound = dicDesktopModulePermissions.TryGetValue(portalDesktopModuleID, out DesktopModulePermissions);
     if (!bFound)
     {
         DesktopModulePermissions = new DesktopModulePermissionCollection(CBO.FillCollection(provider.GetDesktopModulePermissionsByPortalDesktopModuleID(portalDesktopModuleID), typeof(DesktopModulePermissionInfo)), portalDesktopModuleID);
     }
     return DesktopModulePermissions;
 }
 public static bool HasDesktopModulePermission(DesktopModulePermissionCollection objDesktopModulePermissions, string permissionKey)
 {
     return PortalSecurity.IsInRoles(objDesktopModulePermissions.ToString(permissionKey));
 }
Beispiel #11
0
        private static void UpgradeToVersion_500()
        {
            PortalController objPortals = new PortalController();
            ArrayList arrPortals = objPortals.GetPortals();
            TabController controller = new TabController();

            //Add Edit Permissions for Admin Tabs to legacy portals
            PermissionController permissionControler = new PermissionController();
            TabPermissionController tabPermissionControler = new TabPermissionController();
            ArrayList permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT");
            int permissionID = Null.NullInteger;
            if (permissions.Count == 1)
            {
                PermissionInfo permission = permissions[0] as PermissionInfo;
                permissionID = permission.PermissionID;

                foreach (PortalInfo portal in arrPortals)
                {
                    TabInfo adminTab = controller.GetTab(portal.AdminTabId, portal.PortalID, true);
                    if (adminTab != null)
                    {
                        TabPermissionInfo tabPermission = new TabPermissionInfo();
                        tabPermission.TabID = adminTab.TabID;
                        tabPermission.PermissionID = permissionID;
                        tabPermission.AllowAccess = true;
                        tabPermission.RoleID = portal.AdministratorRoleId;
                        if (!TabPermissionExists(tabPermission, portal.PortalID))
                        {
                            adminTab.TabPermissions.Add(tabPermission);
                        }

                        //Save Tab Permissions to Data Base
                        TabPermissionController.SaveTabPermissions(adminTab);

                        foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID))
                        {
                            tabPermission = new TabPermissionInfo();
                            tabPermission.TabID = childTab.TabID;
                            tabPermission.PermissionID = permissionID;
                            tabPermission.AllowAccess = true;
                            tabPermission.RoleID = portal.AdministratorRoleId;
                            if (!TabPermissionExists(tabPermission, portal.PortalID))
                            {
                                childTab.TabPermissions.Add(tabPermission);
                            }
                            //Save Tab Permissions to Data Base
                            TabPermissionController.SaveTabPermissions(childTab);
                        }
                    }
                }
            }

            //Update Host/Admin modules Visibility setting
            bool superTabProcessed = Null.NullBoolean;
            ModuleController moduleController = new ModuleController();
            foreach (PortalInfo portal in arrPortals)
            {
                if (!superTabProcessed)
                {
                    //Process Host Tabs
                    foreach (TabInfo childTab in TabController.GetTabsByParent(portal.SuperTabId, Null.NullInteger))
                    {
                        foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values)
                        {
                            tabModule.Visibility = VisibilityState.None;
                            moduleController.UpdateModule(tabModule);
                        }
                    }
                }

                //Process Portal Tabs
                foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID))
                {
                    foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values)
                    {
                        tabModule.Visibility = VisibilityState.None;
                        moduleController.UpdateModule(tabModule);
                    }
                }
            }

            //Upgrade PortalDesktopModules to support new "model"
            permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY");
            if (permissions.Count == 1)
            {
                PermissionInfo permission = permissions[0] as PermissionInfo;
                permissionID = permission.PermissionID;
                foreach (PortalInfo portal in arrPortals)
                {
                    foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
                    {
                        if (!desktopModule.IsPremium)
                        {
                            //Parse the permissions
                            DesktopModulePermissionCollection deployPermissions = new DesktopModulePermissionCollection();
                            DesktopModulePermissionInfo deployPermission = default(DesktopModulePermissionInfo);

                            // if Not IsAdmin add Registered Users
                            if (!desktopModule.IsAdmin)
                            {
                                deployPermission = new DesktopModulePermissionInfo();
                                deployPermission.PermissionID = permissionID;
                                deployPermission.AllowAccess = true;
                                deployPermission.RoleID = portal.RegisteredRoleId;
                                deployPermissions.Add(deployPermission);
                            }

                            // if Not a Host Module add Administrators
                            string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions";
                            if (!hostModules.Contains(desktopModule.ModuleName))
                            {
                                deployPermission = new DesktopModulePermissionInfo();
                                deployPermission.PermissionID = permissionID;
                                deployPermission.AllowAccess = true;
                                deployPermission.RoleID = portal.AdministratorRoleId;
                                deployPermissions.Add(deployPermission);
                            }

                            //Add Portal/Module to PortalDesktopModules
                            DesktopModuleController.AddDesktopModuleToPortal(portal.PortalID, desktopModule, deployPermissions, false);
                        }
                    }

                    DataCache.ClearPortalCache(portal.PortalID, true);
                }
            }

            LegacyUtil.ProcessLegacyModules();
            LegacyUtil.ProcessLegacyLanguages();
            LegacyUtil.ProcessLegacySkins();
            LegacyUtil.ProcessLegacySkinControls();
        }
Beispiel #12
0
 public DesktopModulePermissionCollection(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     AddRange(DesktopModulePermissions);
 }
 public static bool HasDesktopModulePermission(DesktopModulePermissionCollection objDesktopModulePermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objDesktopModulePermissions.ToString(permissionKey)));
 }
 public DesktopModulePermissionCollection(DesktopModulePermissionCollection DesktopModulePermissions)
 {
     AddRange(DesktopModulePermissions);
 }
 private void ParsePortalDesktopModules(XPathNavigator nav, int portalID)
 {
     string friendlyName = Null.NullString;
     DesktopModuleInfo desktopModule = null;
     foreach (XPathNavigator desktopModuleNav in nav.Select("portalDesktopModule"))
     {
         friendlyName = XmlUtils.GetNodeValue(desktopModuleNav, "friendlyname");
         if (!string.IsNullOrEmpty(friendlyName))
         {
             desktopModule = DesktopModuleController.GetDesktopModuleByFriendlyName(friendlyName);
             if (desktopModule != null)
             {
                 DesktopModulePermissionCollection permissions = new DesktopModulePermissionCollection();
                 foreach (XPathNavigator permissionNav in desktopModuleNav.Select("portalDesktopModulePermissions/portalDesktopModulePermission"))
                 {
                     string code = XmlUtils.GetNodeValue(permissionNav, "permissioncode");
                     string key = XmlUtils.GetNodeValue(permissionNav, "permissionkey");
                     DesktopModulePermissionInfo desktopModulePermission = null;
                     ArrayList arrPermissions = new PermissionController().GetPermissionByCodeAndKey(code, key);
                     if (arrPermissions.Count > 0)
                     {
                         PermissionInfo permission = arrPermissions[0] as PermissionInfo;
                         if (permission != null)
                         {
                             desktopModulePermission = new DesktopModulePermissionInfo(permission);
                         }
                     }
                     desktopModulePermission.AllowAccess = bool.Parse(XmlUtils.GetNodeValue(permissionNav, "allowaccess"));
                     string rolename = XmlUtils.GetNodeValue(permissionNav, "rolename");
                     if (!string.IsNullOrEmpty(rolename))
                     {
                         RoleInfo role = new RoleController().GetRoleByName(portalID, rolename);
                         if (role != null)
                         {
                             desktopModulePermission.RoleID = role.RoleID;
                         }
                     }
                     permissions.Add(desktopModulePermission);
                 }
                 DesktopModuleController.AddDesktopModuleToPortal(portalID, desktopModule, permissions, false);
             }
         }
     }
 }