Beispiel #1
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
            srcUsers.StopProcessing = true;
        }
        else
        {
            TreeNode     node = null;
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

            // Check if path is set
            if (String.IsNullOrEmpty(Path))
            {
                TreeNode curDoc = CMSContext.CurrentDocument;
                // Check if current document is department
                if ((curDoc != null) && (curDoc.NodeClassName.ToLower() == DEPARTMENT_CLASS_NAME))
                {
                    node = CMSContext.CurrentDocument;
                }
            }
            else
            {
                // Obtain document from specified path
                node = tree.SelectSingleNode(SiteName, Path, CMSContext.PreferredCultureCode, true, DEPARTMENT_CLASS_NAME, false, false, false);
            }

            AclProvider aclProv = new AclProvider(tree);
            // If department document exists and has own ACL continue with initializing controls
            if ((node != null) && aclProv.HasOwnACL(node))
            {
                // Get users and roles with read permission for department document
                int     aclId   = ValidationHelper.GetInteger(node.GetValue("NodeACLID"), 0);
                DataSet dsRoles = aclProv.GetAllowedRoles(aclId, NodePermissionsEnum.Read, "RoleID");
                DataSet dsUsers = aclProv.GetAllowedUsers(aclId, NodePermissionsEnum.Read, "UserID");

                string where = null;

                // Process users dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsUsers))
                {
                    // Get allowed users ids
                    IList <string> users   = SqlHelperClass.GetStringValues(dsUsers.Tables[0], "UserID");
                    string         userIds = TextHelper.Join(", ", users);

                    // Populate where condition with user condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (" + userIds + ")", where);
                }

                // Process roles dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsRoles))
                {
                    // Get allowed roles ids
                    IList <string> roles   = SqlHelperClass.GetStringValues(dsRoles.Tables[0], "RoleID");
                    string         roleIds = TextHelper.Join(", ", roles);

                    // Populate where condition with role condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (SELECT UserID FROM View_CMS_UserRole_MembershipRole_ValidOnly_Joined WHERE RoleID IN (" + roleIds + "))", where, "OR");
                }


                if (!String.IsNullOrEmpty(where))
                {
                    // Check if exist where condition and add it to current where condition
                    where = SqlHelperClass.AddWhereCondition(WhereCondition, where);

                    // Set datasource properties
                    srcUsers.WhereCondition     = where;
                    srcUsers.OrderBy            = OrderBy;
                    srcUsers.TopN               = SelectTopN;
                    srcUsers.FilterName         = ValidationHelper.GetString(GetValue("WebPartControlID"), ClientID);
                    srcUsers.SourceFilterName   = FilterName;
                    srcUsers.SiteName           = SiteName;
                    srcUsers.CacheItemName      = CacheItemName;
                    srcUsers.CacheDependencies  = CacheDependencies;
                    srcUsers.CacheMinutes       = CacheMinutes;
                    srcUsers.SelectOnlyApproved = SelectOnlyApproved;
                    srcUsers.SelectHidden       = SelectHidden;
                    srcUsers.SelectedColumns    = Columns;
                }
                else
                {
                    srcUsers.StopProcessing = true;
                }
            }
            else
            {
                srcUsers.StopProcessing = true;
            }
        }
    }
    /// <summary>
    /// PreRender action on which security settings are set.
    /// </summary>
    void Page_PreRender(object sender, EventArgs e)
    {
        if (mDocumentSaved)
        {
            TreeNode editedNode = Form.EditedObject as TreeNode;

            // Create or rebuild department content index
            CreateDepartmentContentSearchIndex(editedNode);

            AclProvider aclProv = new AclProvider(editedNode.TreeProvider);
            if (aclProv.HasOwnACL(editedNode))
            {
                ForumInfo fi = ForumInfoProvider.GetForumInfo("Default_department_" + editedNode.NodeGUID, CMSContext.CurrentSiteID);
                MediaLibraryInfo mi = MediaLibraryInfoProvider.GetMediaLibraryInfo("Department_" + editedNode.NodeGUID, CMSContext.CurrentSiteName);

                // Check if forum of media library exists
                if ((fi != null) || (mi != null))
                {
                    // Get allowed roles ID
                    int aclID = ValidationHelper.GetInteger(editedNode.GetValue("NodeACLID"), 0);
                    DataSet listRoles = aclProv.GetAllowedRoles(aclID, NodePermissionsEnum.Read, "RoleID");
                    string roleIDs = null;

                    if (!DataHelper.DataSourceIsEmpty(listRoles))
                    {
                        IList<string> roles = SqlHelperClass.GetStringValues(listRoles.Tables[0], "RoleID");
                        roleIDs = TextHelper.Join(";", roles);
                    }

                    // Set permissions for forum
                    if (fi != null)
                    {
                        // Get resource object
                        ResourceInfo resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums");

                        // Get permissions IDs
                        DataSet dsForumPerm = PermissionNameInfoProvider.GetPermissionNames("ResourceID = " + resForums.ResourceId + " AND (PermissionName != '" + CMSAdminControl.PERMISSION_READ + "' AND PermissionName != '" + CMSAdminControl.PERMISSION_MODIFY + "')", null, 0, "PermissionID");
                        string forumPermissions = null;
                        if (!DataHelper.DataSourceIsEmpty(dsForumPerm))
                        {
                            foreach (DataRow drForumPerm in dsForumPerm.Tables[0].Rows)
                            {
                                forumPermissions += drForumPerm["PermissionID"] + ";";
                            }
                            forumPermissions = forumPermissions.TrimEnd(';');
                        }

                        // Delete old permissions apart attach file permission
                        ForumRoleInfoProvider.DeleteAllRoles("ForumID = " + fi.ForumID + " AND PermissionID IN (" + forumPermissions.Replace(";", ", ") + ")");

                        // Set forum permissions
                        ForumRoleInfoProvider.SetPermissions(fi.ForumID, roleIDs, forumPermissions);

                        // Log staging task
                        SynchronizationHelper.LogObjectChange(fi, TaskTypeEnum.UpdateObject);
                    }

                    // Set permissions for media library
                    if (mi != null)
                    {
                        // Get resource object
                        ResourceInfo resMediaLibs = ResourceInfoProvider.GetResourceInfo("CMS.MediaLibrary");

                        // Get permissions IDs
                        DataSet dsMediaLibPerm = PermissionNameInfoProvider.GetPermissionNames("ResourceID = " + resMediaLibs.ResourceId + " AND (PermissionName = 'LibraryAccess' OR PermissionName = 'FileCreate')", null, 0, "PermissionID");
                        string mediaLibPermissions = null;
                        if (!DataHelper.DataSourceIsEmpty(dsMediaLibPerm))
                        {
                            foreach (DataRow drMediaLibPerm in dsMediaLibPerm.Tables[0].Rows)
                            {
                                mediaLibPermissions += drMediaLibPerm["PermissionID"] + ";";
                            }
                            mediaLibPermissions = mediaLibPermissions.TrimEnd(';');
                        }

                        // Delete old permissions only for Create file and See library content permissions
                        MediaLibraryRolePermissionInfoProvider.DeleteAllRoles("LibraryID = " + mi.LibraryID + " AND PermissionID IN (" + mediaLibPermissions.Replace(";", ", ") + ")");

                        // Set media library permissions
                        MediaLibraryRolePermissionInfoProvider.SetPermissions(mi.LibraryID, roleIDs, mediaLibPermissions);

                        // Log staging task
                        SynchronizationHelper.LogObjectChange(mi, TaskTypeEnum.UpdateObject);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
            filterUsers.StopProcessing = true;
            srcUsers.StopProcessing = true;
        }
        else
        {
            // Set general properties
            repUsers.DataBindByDefault = false;
            pagerElem.PageControl = repUsers.ID;

            filterUsers.Visible = ShowFilterControl;
            filterUsers.OnFilterChanged += filterUsers_OnFilterChanged;
            srcUsers.OnFilterChanged += filterUsers_OnFilterChanged;

            // Basic control properties
            repUsers.HideControlForZeroRows = HideControlForZeroRows;
            repUsers.ZeroRowsText = ZeroRowsText;

            TreeNode node = null;
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

            // Check if path is set
            if (String.IsNullOrEmpty(Path))
            {
                TreeNode curDoc = CMSContext.CurrentDocument;
                // Check if current document is department
                if ((curDoc != null) && (curDoc.NodeClassName.ToLower() == DEPARTMENT_CLASS_NAME))
                {
                    node = CMSContext.CurrentDocument;
                }
            }
            else
            {
                // Obtain document from specified path
                node = tree.SelectSingleNode(SiteName, Path, CMSContext.PreferredCultureCode, true, DEPARTMENT_CLASS_NAME, false, false, false);
            }

            AclProvider aclProv = new AclProvider(tree);
            // If department document exists and has own ACL continue with initializing controls
            if ((node != null) && aclProv.HasOwnACL(node))
            {
                // Get users and roles with read permission for department document
                int aclId = ValidationHelper.GetInteger(node.GetValue("NodeACLID"), 0);
                DataSet dsRoles = aclProv.GetAllowedRoles(aclId, NodePermissionsEnum.Read, "RoleID");
                DataSet dsUsers = aclProv.GetAllowedUsers(aclId, NodePermissionsEnum.Read, "UserID");

                string where = null;

                // Process users dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsUsers))
                {
                    // Get allowed users ids
                    IList<string> users = SqlHelperClass.GetStringValues(dsUsers.Tables[0], "UserID");
                    string userIds = TextHelper.Join(", ", users);

                    // Populate where condition with user condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (" + userIds + ")", where);
                }

                // Process roles dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsRoles))
                {
                    // Get allowed roles ids
                    IList<string> roles = SqlHelperClass.GetStringValues(dsRoles.Tables[0], "RoleID");
                    string roleIds = TextHelper.Join(", ", roles);

                    // Populate where condition with role condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (SELECT UserID FROM View_CMS_UserRole_MembershipRole_ValidOnly_Joined WHERE RoleID IN (" + roleIds + "))", where, "OR");
                }

                if (!String.IsNullOrEmpty(where))
                {
                    // Check if exist where condition and add it to current where condition
                    where = SqlHelperClass.AddWhereCondition(WhereCondition, where);

                    // Data source properties
                    srcUsers.WhereCondition = where;
                    srcUsers.OrderBy = OrderBy;
                    srcUsers.TopN = SelectTopN;
                    srcUsers.SelectedColumns = Columns;
                    srcUsers.SiteName = SiteName;
                    srcUsers.FilterName = filterUsers.ID;
                    srcUsers.SourceFilterName = FilterName;
                    srcUsers.CacheItemName = CacheItemName;
                    srcUsers.CacheDependencies = CacheDependencies;
                    srcUsers.CacheMinutes = CacheMinutes;
                    srcUsers.SelectOnlyApproved = SelectOnlyApproved;
                    srcUsers.SelectHidden = SelectHidden;

                    // Init data properties
                    filterUsers.InitDataProperties(srcUsers);

                    #region "Repeater template properties"

                    // Apply transformations if they exist
                    if (!String.IsNullOrEmpty(TransformationName))
                    {
                        repUsers.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(AlternatingItemTransformationName))
                    {
                        repUsers.AlternatingItemTemplate = CMSDataProperties.LoadTransformation(this, AlternatingItemTransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(FooterTransformationName))
                    {
                        repUsers.FooterTemplate = CMSDataProperties.LoadTransformation(this, FooterTransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(HeaderTransformationName))
                    {
                        repUsers.HeaderTemplate = CMSDataProperties.LoadTransformation(this, HeaderTransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(SeparatorTransformationName))
                    {
                        repUsers.SeparatorTemplate = CMSDataProperties.LoadTransformation(this, SeparatorTransformationName, false);
                    }

                    #endregion

                    // UniPager properties
                    pagerElem.PageSize = PageSize;
                    pagerElem.GroupSize = GroupSize;
                    pagerElem.QueryStringKey = QueryStringKey;
                    pagerElem.DisplayFirstLastAutomatically = DisplayFirstLastAutomatically;
                    pagerElem.DisplayPreviousNextAutomatically = DisplayPreviousNextAutomatically;
                    pagerElem.HidePagerForSinglePage = HidePagerForSinglePage;
                    pagerElem.Enabled = EnablePaging;

                    switch (PagingMode.ToLower())
                    {
                        case "querystring":
                            pagerElem.PagerMode = UniPagerMode.Querystring;
                            break;

                        default:
                            pagerElem.PagerMode = UniPagerMode.PostBack;
                            break;
                    }

                    #region "UniPager template properties"

                    // UniPager template properties
                    if (!String.IsNullOrEmpty(PagesTemplate))
                    {
                        pagerElem.PageNumbersTemplate = CMSDataProperties.LoadTransformation(pagerElem, PagesTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(CurrentPageTemplate))
                    {
                        pagerElem.CurrentPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, CurrentPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(SeparatorTemplate))
                    {
                        pagerElem.PageNumbersSeparatorTemplate = CMSDataProperties.LoadTransformation(pagerElem, SeparatorTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(FirstPageTemplate))
                    {
                        pagerElem.FirstPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, FirstPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(LastPageTemplate))
                    {
                        pagerElem.LastPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, LastPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(PreviousPageTemplate))
                    {
                        pagerElem.PreviousPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, PreviousPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(NextPageTemplate))
                    {
                        pagerElem.NextPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, NextPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(PreviousGroupTemplate))
                    {
                        pagerElem.PreviousGroupTemplate = CMSDataProperties.LoadTransformation(pagerElem, PreviousGroupTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(NextGroupTemplate))
                    {
                        pagerElem.NextGroupTemplate = CMSDataProperties.LoadTransformation(pagerElem, NextGroupTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(DirectPageTemplate))
                    {
                        pagerElem.DirectPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, DirectPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(LayoutTemplate))
                    {
                        pagerElem.LayoutTemplate = CMSDataProperties.LoadTransformation(pagerElem, LayoutTemplate, false);
                    }

                    #endregion

                    // Connects repeater with data source
                    repUsers.DataSource = srcUsers.DataSource;
                    repUsers.DataBind();
                }
                else
                {
                    // Disable datasource
                    srcUsers.StopProcessing = true;
                }

            }
            else
            {
                // Disable datasource
                srcUsers.StopProcessing = true;
            }
        }
    }
    /// <summary>
    /// PreRender action on which security settings are set.
    /// </summary>
    private void Page_PreRender(object sender, EventArgs e)
    {
        if (mDocumentSaved)
        {
            TreeNode editedNode = Form.EditedObject as TreeNode;

            // Create or rebuild department content index
            CreateDepartmentContentSearchIndex(editedNode);

            AclProvider aclProv = new AclProvider(editedNode.TreeProvider);
            if (aclProv.HasOwnACL(editedNode))
            {
                ForumInfo        fi = ForumInfoProvider.GetForumInfo("Default_department_" + editedNode.NodeGUID, CMSContext.CurrentSiteID);
                MediaLibraryInfo mi = MediaLibraryInfoProvider.GetMediaLibraryInfo("Department_" + editedNode.NodeGUID, CMSContext.CurrentSiteName);

                // Check if forum of media library exists
                if ((fi != null) || (mi != null))
                {
                    // Get allowed roles ID
                    int     aclID     = ValidationHelper.GetInteger(editedNode.GetValue("NodeACLID"), 0);
                    DataSet listRoles = aclProv.GetAllowedRoles(aclID, NodePermissionsEnum.Read, "RoleID");
                    string  roleIDs   = null;

                    if (!DataHelper.DataSourceIsEmpty(listRoles))
                    {
                        IList <string> roles = SystemDataHelper.GetStringValues(listRoles.Tables[0], "RoleID");
                        roleIDs = TextHelper.Join(";", roles);
                    }

                    // Set permissions for forum
                    if (fi != null)
                    {
                        // Get resource object
                        ResourceInfo resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums");

                        // Get permissions IDs
                        DataSet dsForumPerm      = PermissionNameInfoProvider.GetPermissionNames("ResourceID = " + resForums.ResourceId + " AND (PermissionName != '" + CMSAdminControl.PERMISSION_READ + "' AND PermissionName != '" + CMSAdminControl.PERMISSION_MODIFY + "')", null, 0, "PermissionID");
                        string  forumPermissions = null;
                        if (!DataHelper.DataSourceIsEmpty(dsForumPerm))
                        {
                            foreach (DataRow drForumPerm in dsForumPerm.Tables[0].Rows)
                            {
                                forumPermissions += drForumPerm["PermissionID"] + ";";
                            }
                            forumPermissions = forumPermissions.TrimEnd(';');
                        }

                        // Delete old permissions apart attach file permission
                        ForumRoleInfoProvider.DeleteAllRoles("ForumID = " + fi.ForumID + " AND PermissionID IN (" + forumPermissions.Replace(";", ", ") + ")");

                        // Set forum permissions
                        ForumRoleInfoProvider.SetPermissions(fi.ForumID, roleIDs, forumPermissions);

                        // Log staging task
                        SynchronizationHelper.LogObjectChange(fi, TaskTypeEnum.UpdateObject);
                    }

                    // Set permissions for media library
                    if (mi != null)
                    {
                        // Get resource object
                        ResourceInfo resMediaLibs = ResourceInfoProvider.GetResourceInfo("CMS.MediaLibrary");

                        // Get permissions IDs
                        DataSet dsMediaLibPerm      = PermissionNameInfoProvider.GetPermissionNames("ResourceID = " + resMediaLibs.ResourceId + " AND (PermissionName = 'LibraryAccess' OR PermissionName = 'FileCreate')", null, 0, "PermissionID");
                        string  mediaLibPermissions = null;
                        if (!DataHelper.DataSourceIsEmpty(dsMediaLibPerm))
                        {
                            foreach (DataRow drMediaLibPerm in dsMediaLibPerm.Tables[0].Rows)
                            {
                                mediaLibPermissions += drMediaLibPerm["PermissionID"] + ";";
                            }
                            mediaLibPermissions = mediaLibPermissions.TrimEnd(';');
                        }

                        // Delete old permissions only for Create file and See library content permissions
                        MediaLibraryRolePermissionInfoProvider.DeleteAllRoles("LibraryID = " + mi.LibraryID + " AND PermissionID IN (" + mediaLibPermissions.Replace(";", ", ") + ")");

                        // Set media library permissions
                        MediaLibraryRolePermissionInfoProvider.SetPermissions(mi.LibraryID, roleIDs, mediaLibPermissions);

                        // Log staging task
                        SynchronizationHelper.LogObjectChange(mi, TaskTypeEnum.UpdateObject);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
            srcUsers.StopProcessing = true;
        }
        else
        {
            TreeNode node = null;
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

            // Check if path is set
            if (String.IsNullOrEmpty(Path))
            {
                TreeNode curDoc = CMSContext.CurrentDocument;
                // Check if current document is department
                if ((curDoc != null) && (curDoc.NodeClassName.ToLower() == DEPARTMENT_CLASS_NAME))
                {
                    node = CMSContext.CurrentDocument;
                }
            }
            else
            {
                // Obtain document from specified path
                node = tree.SelectSingleNode(SiteName, Path, CMSContext.PreferredCultureCode, true, DEPARTMENT_CLASS_NAME, false, false, false);
            }

            AclProvider aclProv = new AclProvider(tree);
            // If department document exists and has own ACL continue with initializing controls
            if ((node != null) && aclProv.HasOwnACL(node))
            {
                // Get users and roles with read permission for department document
                int aclId = ValidationHelper.GetInteger(node.GetValue("NodeACLID"), 0);
                DataSet dsRoles = aclProv.GetAllowedRoles(aclId, NodePermissionsEnum.Read, "RoleID");
                DataSet dsUsers = aclProv.GetAllowedUsers(aclId, NodePermissionsEnum.Read, "UserID");

                string where = null;

                // Process users dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsUsers))
                {
                    // Get allowed users ids
                    IList<string> users = SqlHelperClass.GetStringValues(dsUsers.Tables[0], "UserID");
                    string userIds = TextHelper.Join(", ", users);

                    // Populate where condition with user condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (" + userIds + ")", where);
                }

                // Process roles dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsRoles))
                {
                    // Get allowed roles ids
                    IList<string> roles = SqlHelperClass.GetStringValues(dsRoles.Tables[0], "RoleID");
                    string roleIds = TextHelper.Join(", ", roles);

                    // Populate where condition with role condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (SELECT UserID FROM View_CMS_UserRole_MembershipRole_ValidOnly_Joined WHERE RoleID IN (" + roleIds + "))", where, "OR");
                }

                if (!String.IsNullOrEmpty(where))
                {
                    // Check if exist where condition and add it to current where condition
                    where = SqlHelperClass.AddWhereCondition(WhereCondition, where);

                    // Set datasource properties
                    srcUsers.WhereCondition = where;
                    srcUsers.OrderBy = OrderBy;
                    srcUsers.TopN = SelectTopN;
                    srcUsers.FilterName = ValidationHelper.GetString(GetValue("WebPartControlID"), ClientID);
                    srcUsers.SourceFilterName = FilterName;
                    srcUsers.SiteName = SiteName;
                    srcUsers.CacheItemName = CacheItemName;
                    srcUsers.CacheDependencies = CacheDependencies;
                    srcUsers.CacheMinutes = CacheMinutes;
                    srcUsers.SelectOnlyApproved = SelectOnlyApproved;
                    srcUsers.SelectHidden = SelectHidden;
                    srcUsers.SelectedColumns = Columns;
                }
                else
                {
                    srcUsers.StopProcessing = true;
                }
            }
            else
            {
                srcUsers.StopProcessing = true;
            }

        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
            filterUsers.StopProcessing = true;
            srcUsers.StopProcessing    = true;
        }
        else
        {
            // Set general properties
            repUsers.DataBindByDefault = false;
            pagerElem.PageControl      = repUsers.ID;

            filterUsers.Visible          = ShowFilterControl;
            filterUsers.OnFilterChanged += filterUsers_OnFilterChanged;
            srcUsers.OnFilterChanged    += filterUsers_OnFilterChanged;

            // Basic control properties
            repUsers.HideControlForZeroRows = HideControlForZeroRows;
            repUsers.ZeroRowsText           = ZeroRowsText;


            TreeNode     node = null;
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

            // Check if path is set
            if (String.IsNullOrEmpty(Path))
            {
                TreeNode curDoc = CMSContext.CurrentDocument;
                // Check if current document is department
                if ((curDoc != null) && (curDoc.NodeClassName.ToLowerCSafe() == DEPARTMENT_CLASS_NAME))
                {
                    node = CMSContext.CurrentDocument;
                }
            }
            else
            {
                // Obtain document from specified path
                node = tree.SelectSingleNode(SiteName, Path, CMSContext.PreferredCultureCode, true, DEPARTMENT_CLASS_NAME, false, false, false);
            }

            AclProvider aclProv = new AclProvider(tree);
            // If department document exists and has own ACL continue with initializing controls
            if ((node != null) && aclProv.HasOwnACL(node))
            {
                // Get users and roles with read permission for department document
                int     aclId   = ValidationHelper.GetInteger(node.GetValue("NodeACLID"), 0);
                DataSet dsRoles = aclProv.GetAllowedRoles(aclId, NodePermissionsEnum.Read, "RoleID");
                DataSet dsUsers = aclProv.GetAllowedUsers(aclId, NodePermissionsEnum.Read, "UserID");

                string where = null;

                // Process users dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsUsers))
                {
                    // Get allowed users ids
                    IList <string> users   = SystemDataHelper.GetStringValues(dsUsers.Tables[0], "UserID");
                    string         userIds = TextHelper.Join(", ", users);

                    // Populate where condition with user condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (" + userIds + ")", where);
                }

                // Process roles dataset to where condition
                if (!DataHelper.DataSourceIsEmpty(dsRoles))
                {
                    // Get allowed roles ids
                    IList <string> roles   = SystemDataHelper.GetStringValues(dsRoles.Tables[0], "RoleID");
                    string         roleIds = TextHelper.Join(", ", roles);

                    // Populate where condition with role condition
                    where = SqlHelperClass.AddWhereCondition("UserID IN (SELECT UserID FROM View_CMS_UserRole_MembershipRole_ValidOnly_Joined WHERE RoleID IN (" + roleIds + "))", where, "OR");
                }


                if (!String.IsNullOrEmpty(where))
                {
                    // Check if exist where condition and add it to current where condition
                    where = SqlHelperClass.AddWhereCondition(WhereCondition, where);

                    // Data source properties
                    srcUsers.WhereCondition     = where;
                    srcUsers.OrderBy            = OrderBy;
                    srcUsers.TopN               = SelectTopN;
                    srcUsers.SelectedColumns    = Columns;
                    srcUsers.SiteName           = SiteName;
                    srcUsers.FilterName         = filterUsers.ID;
                    srcUsers.SourceFilterName   = FilterName;
                    srcUsers.CacheItemName      = CacheItemName;
                    srcUsers.CacheDependencies  = CacheDependencies;
                    srcUsers.CacheMinutes       = CacheMinutes;
                    srcUsers.SelectOnlyApproved = SelectOnlyApproved;
                    srcUsers.SelectHidden       = SelectHidden;

                    // Init data properties
                    filterUsers.InitDataProperties(srcUsers);


                    #region "Repeater template properties"

                    // Apply transformations if they exist
                    if (!String.IsNullOrEmpty(TransformationName))
                    {
                        repUsers.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(AlternatingItemTransformationName))
                    {
                        repUsers.AlternatingItemTemplate = CMSDataProperties.LoadTransformation(this, AlternatingItemTransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(FooterTransformationName))
                    {
                        repUsers.FooterTemplate = CMSDataProperties.LoadTransformation(this, FooterTransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(HeaderTransformationName))
                    {
                        repUsers.HeaderTemplate = CMSDataProperties.LoadTransformation(this, HeaderTransformationName, false);
                    }
                    if (!String.IsNullOrEmpty(SeparatorTransformationName))
                    {
                        repUsers.SeparatorTemplate = CMSDataProperties.LoadTransformation(this, SeparatorTransformationName, false);
                    }

                    #endregion


                    // UniPager properties
                    pagerElem.PageSize       = PageSize;
                    pagerElem.GroupSize      = GroupSize;
                    pagerElem.QueryStringKey = QueryStringKey;
                    pagerElem.DisplayFirstLastAutomatically    = DisplayFirstLastAutomatically;
                    pagerElem.DisplayPreviousNextAutomatically = DisplayPreviousNextAutomatically;
                    pagerElem.HidePagerForSinglePage           = HidePagerForSinglePage;
                    pagerElem.Enabled = EnablePaging;

                    switch (PagingMode.ToLowerCSafe())
                    {
                    case "querystring":
                        pagerElem.PagerMode = UniPagerMode.Querystring;
                        break;

                    default:
                        pagerElem.PagerMode = UniPagerMode.PostBack;
                        break;
                    }


                    #region "UniPager template properties"

                    // UniPager template properties
                    if (!String.IsNullOrEmpty(PagesTemplate))
                    {
                        pagerElem.PageNumbersTemplate = CMSDataProperties.LoadTransformation(pagerElem, PagesTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(CurrentPageTemplate))
                    {
                        pagerElem.CurrentPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, CurrentPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(SeparatorTemplate))
                    {
                        pagerElem.PageNumbersSeparatorTemplate = CMSDataProperties.LoadTransformation(pagerElem, SeparatorTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(FirstPageTemplate))
                    {
                        pagerElem.FirstPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, FirstPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(LastPageTemplate))
                    {
                        pagerElem.LastPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, LastPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(PreviousPageTemplate))
                    {
                        pagerElem.PreviousPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, PreviousPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(NextPageTemplate))
                    {
                        pagerElem.NextPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, NextPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(PreviousGroupTemplate))
                    {
                        pagerElem.PreviousGroupTemplate = CMSDataProperties.LoadTransformation(pagerElem, PreviousGroupTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(NextGroupTemplate))
                    {
                        pagerElem.NextGroupTemplate = CMSDataProperties.LoadTransformation(pagerElem, NextGroupTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(DirectPageTemplate))
                    {
                        pagerElem.DirectPageTemplate = CMSDataProperties.LoadTransformation(pagerElem, DirectPageTemplate, false);
                    }

                    if (!String.IsNullOrEmpty(LayoutTemplate))
                    {
                        pagerElem.LayoutTemplate = CMSDataProperties.LoadTransformation(pagerElem, LayoutTemplate, false);
                    }

                    #endregion


                    // Connects repeater with data source
                    repUsers.DataSource = srcUsers.DataSource;
                    repUsers.DataBind();
                }
                else
                {
                    // Disable datasource
                    srcUsers.StopProcessing = true;
                }
            }
            else
            {
                // Disable datasource
                srcUsers.StopProcessing = true;
            }
        }
    }