/// <summary>
        /// Loads currently selected parent users.
        /// </summary>
        /// <param name="forceReload">Forces reload of selected values</param>
        private void LoadParentData(bool forceReload = false)
        {
            // Get the active child users
            DataSet ds = UserHierarchyInfoProvider.GetUserHierarchies(_currentSiteId).WhereEquals("ChildUserId", _currentUserId);

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                _selectedParents = TextHelper.Join(selParent.ValuesSeparator.ToString(), DataHelper.GetStringValues(ds.Tables[0], "ParentUserId"));
                if (!URLHelper.IsPostback() || forceReload)
                {
                    selParent.Value = _selectedParents;
                }
            }
            else
            {
                if (forceReload)
                {
                    selParent.Value = string.Empty;
                }
            }

            // Filtering data on control for child users.
            selChild.WhereCondition = _currentSiteUsersFilter
                                      + (string.IsNullOrWhiteSpace(_selectedParents)
                    ? string.Empty
                    : $" and UserId not in ({_selectedParents})");
        }
Beispiel #2
0
 private void Delete_After(object sender, ObjectEventArgs e)
 {
     if (e.Object.TypeInfo.Equals(UserInfo.TYPEINFO))
     {
         var userId = e.Object.GetIntegerValue("UserID", 0);
         if (userId != 0)
         {
             var userHierarchies = UserHierarchyInfoProvider.GetUserHierarchies()
                                   .WhereEquals("ParentUserId", userId)
                                   .Or()
                                   .WhereEquals("ChildUserId", userId);
             foreach (var uh in userHierarchies)
             {
                 uh.Delete();
             }
         }
     }
 }