Exemple #1
0
        private void AddEditorRole()
        {
            if (ModuleContext.PortalSettings.UserId > 0)
            {
                string OpenContent_EditorsRoleId = PortalController.GetPortalSetting("OpenContent_EditorsRoleId", ModuleContext.PortalId, "");
                if (!string.IsNullOrEmpty(OpenContent_EditorsRoleId))
                {
                    int roleId    = int.Parse(OpenContent_EditorsRoleId);
                    var objModule = ModuleContext.Configuration;
                    //todo: probable DNN bug.  objModule.ModulePermissions doesn't return correct permissions for attached multi-lingual modules
                    //don't alter permissions of modules that are non-default language and that are attached
                    var permExist = objModule.ModulePermissions.Where(tp => tp.RoleID == roleId).Any();
                    if (!permExist)
                    {
                        //todo sacha: add two permissions, read and write; Or better still add all permissions that are available. eg if you installed extra permissions

                        var permissionController = new PermissionController();
                        // view permission
                        var arrSystemModuleViewPermissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
                        var permission          = (PermissionInfo)arrSystemModuleViewPermissions[0];
                        var objModulePermission = new ModulePermissionInfo
                        {
                            ModuleID = ModuleContext.Configuration.ModuleID,
                            //ModuleDefID = permission.ModuleDefID,
                            //PermissionCode = permission.PermissionCode,
                            PermissionID  = permission.PermissionID,
                            PermissionKey = permission.PermissionKey,
                            RoleID        = roleId,
                            //UserID = userId,
                            AllowAccess = true
                        };
                        objModule.ModulePermissions.Add(objModulePermission);

                        // edit permission
                        arrSystemModuleViewPermissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "EDIT");
                        permission          = (PermissionInfo)arrSystemModuleViewPermissions[0];
                        objModulePermission = new ModulePermissionInfo
                        {
                            ModuleID = ModuleContext.Configuration.ModuleID,
                            //ModuleDefID = permission.ModuleDefID,
                            //PermissionCode = permission.PermissionCode,
                            PermissionID  = permission.PermissionID,
                            PermissionKey = permission.PermissionKey,
                            RoleID        = roleId,
                            //UserID = userId,
                            AllowAccess = true
                        };
                        objModule.ModulePermissions.Add(objModulePermission);
                        try
                        {
                            ModulePermissionController.SaveModulePermissions(objModule);
                        }
                        catch (Exception ex)
                        {
                            //Log.Logger.ErrorFormat("Failed to automaticly set the permission. It already exists? tab={0}, moduletitle={1} ", objModule.TabID ,objModule.ModuleTitle);
                        }
                    }
                }
            }
        }
Exemple #2
0
        private TabPermissionCollection CreateTabPermissions()
        {
            TabPermissionCollection returnCollection = new TabPermissionCollection();

            PermissionController pc             = new PermissionController();
            var viewPermission                  = pc.GetPermissionByCodeAndKey("SYSTEM_TAB", "VIEW").ToList <PermissionInfo>();
            var editPermission                  = pc.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT").ToList <PermissionInfo>();
            int adminRoleId                     = PortalSettings.AdministratorRoleId;
            TabPermissionInfo objViewPermission = new TabPermissionInfo(viewPermission[0]);

            objViewPermission.TabID       = PortalSettings.ActiveTab.TabID;
            objViewPermission.RoleID      = PortalSettings.AdministratorRoleId;
            objViewPermission.RoleName    = PortalSettings.AdministratorRoleName;
            objViewPermission.AllowAccess = true;
            objViewPermission.UserID      = Null.NullInteger;
            objViewPermission.DisplayName = "";
            returnCollection.Add(objViewPermission, true);

            TabPermissionInfo objEditPermission = new TabPermissionInfo(editPermission[0]);

            objEditPermission.TabID       = PortalSettings.ActiveTab.TabID;
            objEditPermission.RoleID      = PortalSettings.AdministratorRoleId;
            objEditPermission.RoleName    = PortalSettings.AdministratorRoleName;
            objEditPermission.AllowAccess = true;
            objEditPermission.UserID      = Null.NullInteger;
            objEditPermission.DisplayName = "";
            returnCollection.Add(objEditPermission, true);

            return(returnCollection);
        }
Exemple #3
0
 private void EditCustomer_Load(object sender, EventArgs e)
 {
     ThemeHelper.ChangeFormBackgroundColor(this);
     try
     {
         if (PermissionController.CheckPermission(PermissionType.CUSTOMER_EDIT))
         {
             cust                = controller.GetCustomer(CustId);
             txtName.Text        = cust.Name;
             txtAddress.Text     = cust.Address;
             txtNic.Text         = cust.Nic;
             txtLandLine.Text    = cust.LandLine;
             txtMobile.Text      = cust.Mobile;
             txtDueAmount.Text   = cust.DueAmount.ToString();
             txtLoyalPoints.Text = cust.LoyalPoints.ToString();
         }
         else
         {
             throw new Exception("Access Denied.!");
         }
     }
     catch (Exception exception)
     {
         Helper.MessageHelper.AlertError(exception.Message);
     }
 }
Exemple #4
0
        private static Dictionary <string, IEnumerable <Dictionary <string, object> > > BuildQueryAndRun(App app, string name, string stream, bool includeGuid, ModuleInfo module, Log log)
        {
            log.Add($"build and run query name:{name}, with module:{module?.ModuleID}");
            var query = app.GetQuery(name);

            if (query == null)
            {
                throw HttpErr(HttpStatusCode.NotFound, "query not found", $"query '{name}' not found");
            }

            var permissionChecker     = new PermissionController(query.QueryDefinition, log, module);
            var readExplicitlyAllowed = permissionChecker.UserMay(PermissionGrant.Read);

            var isAdmin = module != null && DotNetNuke.Security.Permissions
                          .ModulePermissionController.CanAdminModule(module);

            // Only return query if permissions ok
            if (!(readExplicitlyAllowed || isAdmin))
            {
                throw HttpErr(HttpStatusCode.Unauthorized, "Request not allowed", $"Request not allowed. User does not have read permissions for query '{name}'");
            }

            var serializer = new Serializer {
                IncludeGuid = includeGuid
            };

            return(serializer.Prepare(query, stream?.Split(',')));
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the permissions from the Database
        /// </summary>
        /// -----------------------------------------------------------------------------
        protected override ArrayList GetPermissions()
        {
            ArrayList perms = PermissionController.GetPermissionsByFolder();

            _systemFolderPermissions = perms.Cast <PermissionInfo>().ToList();
            return(perms);
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            if (!PermissionController.CanManageApplications(this))
            {
                this.DenyAccess();
                return;
            }

            base.OnInit(e);

            this.JobsGrid.NeedDataSource      += this.JobsGrid_NeedDataSource;
            this.JobsGrid.ItemCreated         += this.JobsGrid_ItemCreated;
            this.JobsGrid.ItemCommand         += this.JobsGrid_ItemCommand;
            this.JobsGrid.ItemDataBound       += this.JobsGrid_ItemDataBound;
            this.JobsGrid.DetailTableDataBind += this.JobsGrid_DetailTableDataBind;

            this.PopulateSearchDropDown();

            try
            {
                this.SetLinks();
                this.LocalizeGrid();
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #7
0
        private static TabInfo CreateNewTab(string tabName)
        {
            var portalSettings = PortalSettings.Current;
            var name           = GetAvailableTabName(tabName, string.Empty);

            var tab = new TabInfo();

            tab.PortalID    = portalSettings.PortalId;
            tab.TabName     = name;
            tab.Title       = name;
            tab.IsVisible   = true;
            tab.DisableLink = false;
            tab.IsDeleted   = false;
            tab.IsSuperTab  = false;

            foreach (PermissionInfo p in PermissionController.GetPermissionsByTab())
            {
                switch (p.PermissionKey)
                {
                case "VIEW":
                    AddTabPermission(tab, p, portalSettings.AdministratorRoleId, true);
                    break;

                case "EDIT":
                    AddTabPermission(tab, p, portalSettings.AdministratorRoleId, true);
                    break;
                }
            }

            var tabController = new TabController();

            tabController.AddTab(tab, true);
            return(tab);
        }
        /// <summary>
        /// Check if a user may do something - and throw an error if the permission is not given
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="grant"></param>
        /// <param name="autoAllowAdmin"></param>
        /// <param name="specificItem"></param>
        private void PerformSecurityCheck(string contentType, PermissionGrant grant, bool autoAllowAdmin = false, IEntity specificItem = null)
        {
            // Check if we can find this content-type
            var ctc = new ContentTypeController();

            ctc.SetAppIdAndUser(App.AppId);

            var cache = DataSource.GetCache(null, App.AppId);
            var ct    = cache.GetContentType(contentType);

            if (ct == null)
            {
                ThrowHttpError(HttpStatusCode.NotFound, "Could not find Content Type '" + contentType + "'.", "content-types");
            }

            // Check if the content-type has a GUID as name - only these can have permission assignments
            Guid ctGuid;
            var  staticNameIsGuid = Guid.TryParse(ct.StaticName, out ctGuid);

            if (!staticNameIsGuid)
            {
                ThrowHttpError(HttpStatusCode.Unauthorized, "Content Type '" + contentType + "' is not a standard Content Type - no permissions possible.");
            }

            // Check permissions in 2sxc - or check if the user has admin-right (in which case he's always granted access for these types of content)
            var permissionChecker = new PermissionController(App.ZoneId, App.AppId, ctGuid, specificItem, Dnn.Module);
            var allowed           = permissionChecker.UserMay(grant);

            var isAdmin = autoAllowAdmin && DotNetNuke.Security.Permissions.ModulePermissionController.CanAdminModule(Dnn.Module);

            if (!(allowed || isAdmin))
            {
                ThrowHttpError(HttpStatusCode.Unauthorized, "Request not allowed. User needs permissions to " + grant + " for Content Type '" + contentType + "'.", "permissions");
            }
        }
Exemple #9
0
        public FileSystemState(Permission rootAccess = null, Permission homeAccess = null)
        {
            if (rootAccess == null)
            {
                var permissionController = new PermissionController();
                rootAccess = permissionController.GetCustomPermission(canRead: true, canExecute: true);
            }

            _rootDirectory = new Directory
            {
                Name   = "/",
                Access = rootAccess
            };

            if (homeAccess == null)
            {
                var permissionController = new PermissionController();
                homeAccess = permissionController.GetCustomPermission(canRead: true, canExecute: true);
            }

            _homeDirectory = new Directory
            {
                Name            = "home",
                Access          = homeAccess,
                ParentDirectory = _rootDirectory
            };

            _rootDirectory.SubDirectories.Add(_homeDirectory);
            _currentDirectory = _homeDirectory;
        }
Exemple #10
0
 private void btnNewProduct_Click(object sender, EventArgs e)
 {
     if (PermissionController.CheckPermission(PermissionType.PRODUCT_ADD))
     {
         new AddProduct().Show();
     }
 }
        [ValidateAntiForgeryToken]                                          // currently only available for modules, so always require the security token
        public dynamic Query([FromUri] string name)
        {
            Log.Add($"query name:{name}");
            // use the previously defined query, or just get it from the request (module-mode)
            if (_queryApp == null)
            {
                _queryApp = App;
            }

            var query = GetQueryByName(name);

            var queryConf         = query.QueryDefinition;
            var permissionChecker = new PermissionController(_queryApp.ZoneId, _queryApp.AppId, queryConf.EntityGuid, _useModuleAndCheckModulePermissions ? Dnn.Module : null);
            var readAllowed       = permissionChecker.UserMay(PermissionGrant.Read);

            var isAdmin = _useModuleAndCheckModulePermissions && DotNetNuke.Security.Permissions.ModulePermissionController.CanAdminModule(Dnn.Module);

            // Only return query if permissions ok
            if (!(readAllowed || isAdmin))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized)
                {
                    Content      = new StringContent("Request not allowed. User does not have read permissions for query '" + name + "'"),
                    ReasonPhrase = "Request not allowed"
                });
            }

            return(new Serializer().Prepare(query));
        }
Exemple #12
0
 public PermissionViewer()
 {
     InitializeComponent();
     MyController = new PermissionController(this);
     Controller   = MyController;
     CleanEmptyReportButtons();
 }
        public async Task GetPermissionAsync_WithTestGuid_ReturnsCorrectResult()
        {
            // Arrange
            var permissionService = Substitute.For <IPermissionService>();
            var testGuid          = Guid.NewGuid();
            var testName          = "TestUserName";

            permissionService.GetByIdAsync(testGuid).Returns(new Permission {
                Uuid = testGuid, Name = testName
            });

            var controller = new PermissionController(permissionService, orderByHelper, paginationHelper, mapper);

            // Act
            IActionResult actionResult = await controller.GetPermissionAsync(testGuid);

            // Assert
            var okResult = actionResult as OkObjectResult;

            Assert.NotNull(okResult);

            var permission = okResult.Value as Permission;

            Assert.NotNull(permission);
            Assert.True(permission.Uuid == testGuid, $"Retrieved Id {permission.Uuid} not the same as sample id {testGuid}.");
            Assert.True(permission.Name == testName, $"Retrieved Name {permission.Name} not the same as sample id {testName}.");
        }
Exemple #14
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Permissions from the Data Store
        /// </summary>
        /// -----------------------------------------------------------------------------
        protected override ArrayList GetPermissions()
        {
            var moduleInfo = ModuleController.Instance.GetModule(ModuleID, TabId, false);

            var permissionController = new PermissionController();
            var permissions          = permissionController.GetPermissionsByModule(ModuleID, TabId);

            var permissionList = new ArrayList();

            for (int i = 0; i <= permissions.Count - 1; i++)
            {
                var permission = (PermissionInfo)permissions[i];
                if (permission.PermissionKey == "VIEW")
                {
                    _ViewColumnIndex = i + 1;
                    permissionList.Add(permission);
                }
                else
                {
                    if (!(moduleInfo.IsShared && moduleInfo.IsShareableViewOnly))
                    {
                        permissionList.Add(permission);
                    }
                }
            }
            return(permissionList);
        }
Exemple #15
0
        [ValidateAntiForgeryToken]                                          // currently only available for modules, so always require the security token
        public dynamic Query([FromUri] string name)
        {
            // use the previously defined query, or just get it from the request (module-mode)
            if (_queryApp == null)
            {
                _queryApp = App;
            }

            var query = GetQueryByName(name);

            var queryConf         = query.QueryDefinition;
            var permissionChecker = new PermissionController(_queryApp.ZoneId, _queryApp.AppId, queryConf.EntityGuid, _useModuleAndCheckModulePermissions ? Dnn.Module : null);
            var readAllowed       = permissionChecker.UserMay(PermissionGrant.Read);

            var isAdmin = _useModuleAndCheckModulePermissions && DotNetNuke.Security.Permissions.ModulePermissionController.CanAdminModule(Dnn.Module);

            // Only return query if permissions ok
            if (!(readAllowed || isAdmin))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized)
                {
                    Content      = new StringContent("Request not allowed. User does not have read permissions for query '" + name + "'"),
                    ReasonPhrase = "Request not allowed"
                });
            }

            return(new Serializer().Prepare(query));
            // 2016-05-03 2dm - if it turns out that the serializer on the Sxc-object is better (can't find a reason why)...
            // ...then I would need this variation below:
            //return _useModuleAndCheckModulePermissions
            //    ? Sxc.Serializer.Prepare(query)
            //    : new Serializer().Prepare(query);
        }
Exemple #16
0
        [ValidateAntiForgeryToken]                                          // currently only available for modules, so always require the security token
        public dynamic Query([FromUri] string name)
        {
            // Try to find the query, abort if not found
            if (!App.Query.ContainsKey(name))
            {
                throw new Exception("Can't find Query with name '" + name + "'");
            }

            // Get query, check what permissions were assigned to the query-definition
            var query             = App.Query[name] as DeferredPipelineQuery;
            var queryConf         = query.QueryDefinition;
            var permissionChecker = new PermissionController(App.ZoneId, App.AppId, queryConf.EntityGuid, Dnn.Module);
            var readAllowed       = permissionChecker.UserMay(PermissionGrant.Read);

            var isAdmin = DotNetNuke.Security.Permissions.ModulePermissionController.CanAdminModule(Dnn.Module);

            // Only return query if permissions ok
            if (readAllowed || isAdmin)
            {
                return(Sxc.Serializer.Prepare(query));
            }
            else
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized)
                {
                    Content      = new StringContent("Request not allowed. User does not have read permissions for query '" + name + "'"),
                    ReasonPhrase = "Request not allowed"
                });
            }
        }
Exemple #17
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            int cityID = _cityController.ListALLAsNoTracking()[cmbCity.SelectedIndex].Id;

            if (!haveEmptyField())
            {
                User user = new User()
                {
                    CidadeId       = cityID,
                    Nome           = txtNome.Text.Trim(),
                    Bi             = mskTxtBI.Text != "" && mskTxtBI.Text.Length >= 9 ? mskTxtBI.Text.Remove(0, 4).Trim() : "",
                    Email          = txtEmail.Text.Trim(),
                    DataNascimento = dtpDataNascimento.Value,
                    Sexo           = cmbSexo.SelectedIndex == 0 ? "M" : "F",

                    Endereco = txtAddress.Text.Trim(),
                    Tel      = txtTel.Text.Trim(),
                    Usuario  = txtUser.Text,
                    Senha    = txtSenha.Text,

                    FlagAdmin = cmbAcesso.SelectedIndex == 0 ? true : false,
                    //  FlagStandard = cmbAcesso.SelectedIndex == 0 ? true : false,
                };

                if (_userController.salvar(user) == 0)
                {
                    MessageBox.Show("Erro ao inserir...");
                }
                else
                {
                    /* Colocar aqui o código para atualiar a grid user
                     *  if (_frmProviderView.ctor == 2)
                     *      _frmProviderView.toGvdProviderControlWithProducts();*/
                }
                /*  }*/

                PermissionController _permissionController = new PermissionController();
                if (cmbAcesso.SelectedIndex == 1)
                {
                    _permissionController.insert(new Permission()
                    {
                        Stock     = prStock.Checked,
                        Venda     = prVendas.Checked,
                        UsuarioId = _userController.getLast().Id,
                    });
                }

                _frmUserView.updateGrid();



                clearField();
                Close();
            }
            else
            {
                MessageBox.Show("Preencha todos campos obrigatórios *");
            }
        }
Exemple #18
0
        public IHttpActionResult getLeftRoleTree(string userid)
        {
            RetMsg ret = new RetMsg();

            ret = new PermissionController().getLeftRoleTree(userid);

            return(Json(ret));
        }
Exemple #19
0
        private TabPermissionInfo GetAlreadyPermission(TabInfo tab, string permissionKey, int roleId)
        {
            var permission = PermissionController.GetPermissionsByTab().Cast <PermissionInfo>().SingleOrDefault <PermissionInfo>(p => p.PermissionKey == permissionKey);

            return
                (tab.TabPermissions.Cast <TabPermissionInfo>()
                 .FirstOrDefault(tp => tp.RoleID == roleId && tp.PermissionID == permission.PermissionID));
        }
Exemple #20
0
        /// <summary>
        /// Setup the test
        /// </summary>
        public PermissionApiUnitTest()
        {
            DbContextOptions <DbAppContext> options      = new DbContextOptions <DbAppContext>();
            Mock <DbAppContext>             dbAppContext = new Mock <DbAppContext>(null, options);
            PermissionService _service = new PermissionService(dbAppContext.Object);

            _PermissionApi = new PermissionController(_service);
        }
Exemple #21
0
        public bool HasStateReviewerPermission(PortalSettings settings, UserInfo user, int stateId)
        {
            var permissions = _statePermissionsRepository.GetWorkflowStatePermissionByState(stateId);

            return(user.IsSuperUser ||
                   PortalSecurity.IsInRoles(user, settings, settings.AdministratorRoleName) ||
                   PortalSecurity.IsInRoles(user, settings, PermissionController.BuildPermissions(permissions.ToList(), ReviewPermissionKey)));
        }
Exemple #22
0
        static void DeserializeModulePermissions(XmlNodeList nodeModulePermissions, int portalId, ModuleInfo module)
        {
            var objRoleController       = new RoleController();
            var objPermissionController = new PermissionController();

            foreach (XmlNode node in nodeModulePermissions)
            {
                var permissionKey  = XmlUtils.GetNodeValue(node, "permissionkey", "");
                var permissionCode = XmlUtils.GetNodeValue(node, "permissioncode", "");
                var roleName       = XmlUtils.GetNodeValue(node, "rolename", "");
                var allowAccess    = XmlUtils.GetNodeValueBoolean(node, "allowaccess");

                var roleId = int.MinValue;
                switch (roleName)
                {
                case Globals.glbRoleAllUsersName:
                    roleId = Convert.ToInt32(Globals.glbRoleAllUsers);
                    break;

                case Globals.glbRoleUnauthUserName:
                    roleId = Convert.ToInt32(Globals.glbRoleUnauthUser);
                    break;

                default:
                    var objRole = objRoleController.GetRoleByName(portalId, roleName);
                    if (objRole != null)
                    {
                        roleId = objRole.RoleID;
                    }
                    break;
                }
                if (roleId != int.MinValue)
                {
                    var permissionId   = Convert.ToInt32(-1);
                    var arrPermissions = objPermissionController.GetPermissionByCodeAndKey(permissionCode, permissionKey);

                    int i;
                    for (i = 0; i <= arrPermissions.Count - 1; i++)
                    {
                        var permission = (PermissionInfo)(arrPermissions[i]);
                        permissionId = permission.PermissionID;
                    }

                    // if role was found add, otherwise ignore
                    if (permissionId != -1)
                    {
                        var modulePermission = new ModulePermissionInfo
                        {
                            ModuleID     = module.ModuleID,
                            PermissionID = permissionId,
                            RoleID       = roleId,
                            AllowAccess  = allowAccess
                        };
                        module.ModulePermissions.Add(modulePermission);
                    }
                }
            }
        }
Exemple #23
0
        public void GivenThereIsAPageCalled(string pageName, Table permissions)
        {
            var reset         = false;
            var tabController = new TabController();
            var tab           = tabController.GetTabByName(pageName, PortalId);

            if (tab == null)
            {
                tab = new TabInfo
                {
                    TabName  = pageName,
                    PortalID = 0
                };
                tab.TabID = tabController.AddTab(tab);
                foreach (var row in permissions.Rows)
                {
                    var roleId         = -1;
                    var roleController = new RoleController();
                    if (row[0] == "All Users")
                    {
                        roleId = -1;
                    }
                    else
                    {
                        var role = roleController.GetRoleByName(PortalId, row[0]);
                        if (role == null)
                        {
                            if (roleController.GetRoleByName(Null.NullInteger, row[0]) == null)
                            {
                                role = new RoleInfo {
                                    RoleName = row[0], RoleGroupID = Null.NullInteger
                                };
                                roleId = roleController.AddRole(role);
                            }
                        }
                    }
                    var permissionController = new PermissionController();
                    var permission           = permissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", row[1]);
                    var tabPermission        = new TabPermissionInfo
                    {
                        PermissionID = 3,
                        TabID        = tab.TabID,
                        AllowAccess  = true,
                        RoleID       = roleId
                    };
                    tab.TabPermissions.Add(tabPermission);
                }

                tabController.UpdateTab(tab);
                reset = true;
            }
            Page = tab;
            if (reset)
            {
                Config.Touch();
            }
        }
Exemple #24
0
        private void FeedFormWithUserValues()
        {
            User       user       = User.Find(id);
            Permission permission = Permission.Find(user.permission_id);

            input_username.Text = user.name;
            input_email.Text    = user.email;
            PermissionController.FeedComboBoxForEdit(combobox_rol, permission.permission_name);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// SaveModuleDefinition saves the Module Definition to the database
        /// </summary>
        /// <param name="moduleDefinition">The Module Definition to save</param>
        /// <param name="saveChildren">A flag that determines whether the child objects are also saved</param>
        /// <param name="clearCache">A flag that determines whether to clear the host cache</param>
        /// <history>
        ///     [cnurse]	01/14/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache)
        {
            int moduleDefinitionID = moduleDefinition.ModuleDefID;

            if (moduleDefinitionID == Null.NullInteger)
            {
                //Add new Module Definition
                moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID,
                                                                      moduleDefinition.FriendlyName,
                                                                      moduleDefinition.DefinitionName,
                                                                      moduleDefinition.DefaultCacheTime,
                                                                      UserController.GetCurrentUserInfo().UserID);
            }
            else
            {
                //Upgrade Module Definition
                dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefinitionName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
            }
            if (saveChildren)
            {
                foreach (KeyValuePair <string, PermissionInfo> kvp in moduleDefinition.Permissions)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;

                    //check if permission exists
                    var       permissionController = new PermissionController();
                    ArrayList permissions          = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey);
                    if (permissions != null && permissions.Count == 1)
                    {
                        var 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;

                    //check if definition exists
                    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);
        }
Exemple #26
0
 public RegisterForm(LayoutForm layoutForm)
 {
     InitializeComponent();
     is_password_validated       = false;
     this.information_label.Text = "";
     this.successfullColor       = Color.FromArgb(21, 87, 36);
     this.wrongColor             = information_label.ForeColor;
     _layoutForm = layoutForm;
     PermissionController.FeedComboBox(combobox_rol);
 }
        private static void AddModulePermission(ModulePermissionCollection permissions, string key, int roleId)
        {
            var permissionController = new PermissionController();
            var permission           = (PermissionInfo)permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", key)[0];
            var modulePermission     = new ModulePermissionInfo {
                PermissionID = permission.PermissionID, RoleID = roleId, AllowAccess = true
            };

            permissions.Add(modulePermission);
        }
        public static void DeserializeTabPermissions(XmlNodeList nodeTabPermissions, TabInfo tab)
        {
            var permissionController = new PermissionController();

            foreach (XmlNode xmlTabPermission in nodeTabPermissions)
            {
                var permissionKey  = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "permissionkey");
                var permissionCode = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "permissioncode");
                var roleName       = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "rolename");
                var allowAccess    = XmlUtils.GetNodeValueBoolean(xmlTabPermission, "allowaccess");
                var permissions    = permissionController.GetPermissionByCodeAndKey(permissionCode, permissionKey);
                var permissionId   = permissions.Cast <PermissionInfo>().Last().PermissionID;

                var roleId = int.MinValue;
                switch (roleName)
                {
                case Globals.glbRoleAllUsersName:
                    roleId = Convert.ToInt32(Globals.glbRoleAllUsers);
                    break;

                case Globals.glbRoleUnauthUserName:
                    roleId = Convert.ToInt32(Globals.glbRoleUnauthUser);
                    break;

                default:
                    var portal = PortalController.Instance.GetPortal(tab.PortalID);
                    var role   = RoleController.Instance.GetRole(portal.PortalID, r => r.RoleName == roleName);
                    if (role != null)
                    {
                        roleId = role.RoleID;
                    }

                    break;
                }

                if (roleId != int.MinValue &&
                    !tab.TabPermissions.Cast <TabPermissionInfo>().Any(p =>
                                                                       p.RoleID == roleId &&
                                                                       p.PermissionID == permissionId))
                {
                    var tabPermission = new TabPermissionInfo
                    {
                        TabID        = tab.TabID,
                        PermissionID = permissionId,
                        RoleID       = roleId,
                        AllowAccess  = allowAccess,
                    };

                    tab.TabPermissions.Add(tabPermission);
                }
            }

            TabController.Instance.UpdateTab(tab);
        }
Exemple #29
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     if (PermissionController.CheckPermission(PermissionType.CUSTOMER_ADD))
     {
         new AddCustomer().Show();
     }
     else
     {
         Helper.MessageHelper.AlertError("Access Denied!");
     }
 }
Exemple #30
0
        public void Initalize()
        {
            _fakePermissionService = new Mock <IPermissionService>();
            _fakePermissionService.SetupAllProperties();
            _fakePermissionService.Setup(s => s.GetAllPermissions()).ReturnsAsync(_testPermissions);
            _fakePermissionService.Setup(s => s.GetPermissionByUserId(It.IsAny <int>())).ReturnsAsync(_testPermissions[0]);
            _fakePermissionService.Setup(s => s.AddPermission(It.IsAny <Permission>())).ReturnsAsync(_testPermissions[0]);
            _fakePermissionService.Setup(s => s.DeletePermission(It.IsAny <int>())).ReturnsAsync(_testPermissions[0]);

            _testPermissionController = new PermissionController(_fakePermissionService.Object);
        }
 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;
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Permissions from the Data Store
        /// </summary>
        /// -----------------------------------------------------------------------------
        protected override ArrayList GetPermissions()
        {
            var moduleInfo = TestableModuleController.Instance.GetModule(ModuleID, TabId);

            var permissionController = new PermissionController();
            var permissions = permissionController.GetPermissionsByModuleID(ModuleID);

            var permissionList = new ArrayList();
            for (int i = 0; i <= permissions.Count - 1; i++)
            {
                var permission = (PermissionInfo)permissions[i];
                if (permission.PermissionKey == "VIEW")
                {
                    _ViewColumnIndex = i + 1;
                    permissionList.Add(permission);
                }
                else
                {
                    if (!(moduleInfo.IsShared && moduleInfo.IsShareableViewOnly))
                    {
                        permissionList.Add(permission);
                    }
                }
            }
            return permissionList;
        }
 /// <summary>
 /// Gets the permissions from the Database
 /// </summary>
 protected override ArrayList GetPermissions()
 {
     PermissionController objPermissionController = new PermissionController();
     return objPermissionController.GetPermissionsByTabID( this.TabID );
 }
        protected void loadPermissionToChkBoxListPermission(string permissions)
        {
            PermissionController permission_obj = new PermissionController();
            DataTable dt = permission_obj.GetPermissionsByCode("SYSTEM_TAB");

            CheckBoxList_Permission.DataSource = dt;
            CheckBoxList_Permission.DataTextField = "PermissionName";
            CheckBoxList_Permission.DataValueField = "PermissionId";
            CheckBoxList_Permission.DataBind();

            string[] arr_result = permissions.Split(new string[] { "," }, StringSplitOptions.None);
            for (int i = 0; i < CheckBoxList_Permission.Items.Count; i++)
            {
                for (int x = 0; x < arr_result.Length; x++)
                {
                    if (CheckBoxList_Permission.Items[i].Value == arr_result[x])
                    {
                        CheckBoxList_Permission.Items[i].Selected = true;
                    }
                }
            }           
        }
 public void DeleteModuleDefinition(int moduleDefinitionId)
 {
     PermissionController permissionController = new PermissionController();
     foreach (PermissionInfo permission in permissionController.GetPermissionsByModuleDefID(moduleDefinitionId))
     {
         permissionController.DeletePermission(permission.PermissionID);
     }
     dataProvider.DeleteModuleDefinition(moduleDefinitionId);
     DataCache.ClearHostCache(true);
 }
        protected void loadPermissionToChkBoxListPermission()
        {
            PermissionController permission_obj = new PermissionController();
            DataTable dt = permission_obj.GetPermissionsByCode("SYSTEM_TAB");

            CheckBoxList_Permission.DataSource = dt;
            CheckBoxList_Permission.DataTextField = "PermissionName";
            CheckBoxList_Permission.DataValueField = "PermissionId";
            CheckBoxList_Permission.DataBind();

            //ArrayList array_data = new ArrayList();
            //array_data.Add(new ListItem("View", "V"));
            //array_data.Add(new ListItem("Insert", "I"));
            //array_data.Add(new ListItem("Update", "U"));
            //array_data.Add(new ListItem("Security", "S"));
            //array_data.Add(new ListItem("History", "H"));

            //CheckBoxList_Permission.DataSource = array_data;
            //CheckBoxList_Permission.DataTextField = "Text";
            //CheckBoxList_Permission.DataValueField = "Value";
            //CheckBoxList_Permission.DataBind();
        }
        public CascadingDropDownNameValue[] GetPermissionList(string knownCategoryValues, string category)
        {
            StringDictionary dataValues = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            int ModuleId =Convert.ToInt32(dataValues["ModuleId"]);
            PermissionController permission_obj = new PermissionController();
            DataTable dt = permission_obj.GetPermissionsByModuleId(ModuleId);

            List<CascadingDropDownNameValue> permission_list = new List<CascadingDropDownNameValue>();
            foreach (DataRow dRow in dt.Rows)
            {
                string PermissionId = dRow["PermissionId"].ToString();
                string PermissionName = dRow["PermissionName"].ToString();
                permission_list.Add(new CascadingDropDownNameValue(PermissionName, PermissionId));
            }
            return permission_list.ToArray();
        }
 /// <summary>
 /// Gets the permissions from the Database
 /// </summary>
 protected override ArrayList GetPermissions()
 {
     PermissionController objPermissionController = new PermissionController();
     return objPermissionController.GetPermissionsByFolder( PortalId, this.FolderPath );
 }
 private void LoadPermissionList2DDL()
 {
     ddlPermissionList.Items.Clear();
     PermissionController permission_obj = new PermissionController();
     DataTable dt_permission = permission_obj.GetPermissionsByCode("SYSTEM_MODULE");
     ddlPermissionList.DataSource = dt_permission;
     ddlPermissionList.DataTextField = "PermissionName";
     ddlPermissionList.DataValueField = "PermissionId";
     ddlPermissionList.DataBind();
     // ddlPermissionList.Items.Insert(0, new ListItem("- Chọn -", "0"));
     ddlPermissionList.SelectedIndex = 0;
     ddlPermissionList.AutoPostBack = true;            
 }
 private static void DeserializeModulePermissions(XmlNodeList nodeModulePermissions, int PortalId, int TabId, ModuleInfo objModule)
 {
     RoleController objRoleController = new RoleController();
     PermissionController objPermissionController = new PermissionController();
     PermissionInfo objPermission;
     int PermissionID;
     ArrayList arrPermissions;
     int i;
     foreach (XmlNode node in nodeModulePermissions)
     {
         string PermissionKey = XmlUtils.GetNodeValue(node.CreateNavigator(), "permissionkey");
         string PermissionCode = XmlUtils.GetNodeValue(node.CreateNavigator(), "permissioncode");
         string RoleName = XmlUtils.GetNodeValue(node.CreateNavigator(), "rolename");
         bool AllowAccess = XmlUtils.GetNodeValueBoolean(node, "allowaccess");
         int RoleID = int.MinValue;
         switch (RoleName)
         {
             case Globals.glbRoleAllUsersName:
                 RoleID = Convert.ToInt32(Globals.glbRoleAllUsers);
                 break;
             case Common.Globals.glbRoleUnauthUserName:
                 RoleID = Convert.ToInt32(Globals.glbRoleUnauthUser);
                 break;
             default:
                 RoleInfo objRole = objRoleController.GetRoleByName(PortalId, RoleName);
                 if (objRole != null)
                 {
                     RoleID = objRole.RoleID;
                 }
                 break;
         }
         if (RoleID != int.MinValue)
         {
             PermissionID = -1;
             arrPermissions = objPermissionController.GetPermissionByCodeAndKey(PermissionCode, PermissionKey);
             for (i = 0; i <= arrPermissions.Count - 1; i++)
             {
                 objPermission = (PermissionInfo)arrPermissions[i];
                 PermissionID = objPermission.PermissionID;
             }
             if (PermissionID != -1)
             {
                 ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
                 objModulePermission.ModuleID = objModule.ModuleID;
                 objModulePermission.PermissionID = PermissionID;
                 objModulePermission.RoleID = RoleID;
                 objModulePermission.AllowAccess = Convert.ToBoolean(XmlUtils.GetNodeValue(node.CreateNavigator(), "allowaccess"));
                 objModule.ModulePermissions.Add(objModulePermission);
             }
         }
     }
 }
        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();
        }
 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);
             }
         }
     }
 }
 protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align)
 {
     TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions;
     PermissionController objPermissionController = new PermissionController();
     ModuleController objModules = new ModuleController();
     Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
     int j;
     try
     {
         DesktopModuleInfo desktopModule = null;
         if (!DesktopModuleController.GetDesktopModules(PortalSettings.PortalId).TryGetValue(desktopModuleId, out desktopModule))
         {
             throw new ArgumentException("desktopModuleId");
         }
     }
     catch (Exception ex)
     {
         Exceptions.LogException(ex);
     }
     int UserId = -1;
     if (Request.IsAuthenticated)
     {
         UserInfo objUserInfo = UserController.GetCurrentUserInfo();
         UserId = objUserInfo.UserID;
     }
     foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
     {
         ModuleInfo objModule = new ModuleInfo();
         objModule.Initialize(PortalSettings.PortalId);
         objModule.PortalID = PortalSettings.PortalId;
         objModule.TabID = PortalSettings.ActiveTab.TabID;
         objModule.ModuleOrder = position;
         if (String.IsNullOrEmpty(title))
         {
             objModule.ModuleTitle = objModuleDefinition.FriendlyName;
         }
         else
         {
             objModule.ModuleTitle = title;
         }
         objModule.PaneName = paneName;
         objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
         if (objModuleDefinition.DefaultCacheTime > 0)
         {
             objModule.CacheTime = objModuleDefinition.DefaultCacheTime;
             if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger)
             {
                 ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true);
                 if (defaultModule != null)
                 {
                     objModule.CacheTime = defaultModule.CacheTime;
                 }
             }
         }
         switch (permissionType)
         {
             case ViewPermissionType.View:
                 objModule.InheritViewPermissions = true;
                 break;
             case ViewPermissionType.Edit:
                 objModule.InheritViewPermissions = false;
                 break;
         }
         ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
         foreach (TabPermissionInfo objTabPermission in objTabPermissions)
         {
             if (objTabPermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.View)
             {
                 continue;
             }
             ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
             for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
             {
                 PermissionInfo objSystemModulePermission;
                 objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j];
                 if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.Edit && objTabPermission.PermissionKey != "EDIT")
                 {
                     continue;
                 }
                 ModulePermissionInfo objModulePermission = AddModulePermission(objModule, objSystemModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess);
                 if (objModulePermission.PermissionKey == "EDIT" && objModulePermission.AllowAccess)
                 {
                     ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule, (PermissionInfo)arrSystemModuleViewPermissions[0], objModulePermission.RoleID, objModulePermission.UserID, true);
                 }
             }
             if (objTabPermission.PermissionKey == "EDIT")
             {
                 ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID);
                 for (j = 0; j <= arrCustomModulePermissions.Count - 1; j++)
                 {
                     PermissionInfo objCustomModulePermission;
                     objCustomModulePermission = (PermissionInfo)arrCustomModulePermissions[j];
                     AddModulePermission(objModule, objCustomModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess);
                 }
             }
         }
         objModule.AllTabs = false;
         objModule.Alignment = align;
         objModules.AddModule(objModule);
     }
 }
Exemple #44
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the Permissions from the Data Store
 /// </summary>
 /// <history>
 ///     [cnurse]    01/09/2006  Documented
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override ArrayList GetPermissions()
 {
     var objPermissionController = new PermissionController();
     ArrayList arrPermissions = objPermissionController.GetPermissionsByModuleID(ModuleID);
     int i;
     for (i = 0; i <= arrPermissions.Count - 1; i++)
     {
         PermissionInfo objPermission;
         objPermission = (PermissionInfo)arrPermissions[i];
         if (objPermission.PermissionKey == "VIEW")
         {
             _ViewColumnIndex = i + 1;
         }
     }
     return arrPermissions;
 }
 private void AddFolderPermissions(int PortalId, int folderId)
 {
     PortalInfo objPortal = GetPortal(PortalId);
     FolderController objController = new FolderController();
     FolderPermissionInfo objFolderPermission;
     FolderInfo folder = objController.GetFolderInfo(PortalId, folderId);
     PermissionController objPermissionController = new PermissionController();
     foreach (PermissionInfo objpermission in objPermissionController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", ""))
     {
         objFolderPermission = new FolderPermissionInfo(objpermission);
         objFolderPermission.FolderID = folder.FolderID;
         objFolderPermission.RoleID = objPortal.AdministratorRoleId;
         folder.FolderPermissions.Add(objFolderPermission);
         if (objpermission.PermissionKey == "READ")
         {
             objFolderPermission = new FolderPermissionInfo(objpermission);
             objFolderPermission.FolderID = folder.FolderID;
             objFolderPermission.RoleID = int.Parse(Globals.glbRoleAllUsers);
             folder.FolderPermissions.Add(objFolderPermission);
         }
     }
     FolderPermissionController.SaveFolderPermissions(folder);
 }