Exemplo n.º 1
0
        public int SavePermissions(int groupId, int forumId, Permission permission)
        {
            string[] fieldNames = { "GroupID", "ForumID" };
            string[] fieldValues = { groupId.ToString(), forumId.ToString() };
            SharePointListItem listItem = Provider.GetListItemByField(ForumConstants.Lists_ForumAccess, fieldNames, fieldValues);

            int rc = 0;
            if (listItem == null)
            {
                string[] values = {
									  "Title", permission.ToString(),
									  "GroupID", groupId.ToString(),
									  "ForumID", forumId.ToString(),
				};

                listItem = new SharePointListItem(0, values);
                rc = Provider.AddListItem(ForumConstants.Lists_ForumAccess, listItem);
            }
            else
            {
                listItem["Title"] = permission.ToString();
                rc = Provider.UpdateListItem(ForumConstants.Lists_ForumAccess, listItem);
            }

            return rc;
        }
Exemplo n.º 2
0
 public Hashtable GetPermissionsForForum(int id)
 {
     Hashtable permissions = new Hashtable();
     SharePointListDescriptor listItems = Provider.GetListItemsByField(ForumConstants.Lists_ForumAccess, "ForumID", id.ToString());
     foreach (SharePointListItem listItem in listItems.SharePointListItems)
     {
         Permission perm = new Permission(listItem["Title"]);
         permissions.Add(Convert.ToInt32(listItem["GroupID"]), perm);
     }
     return permissions;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Determines whether the specified user has access 
        /// to any forum in the category.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="right">The right.</param>
        /// <returns>
        /// 	<c>true</c> if the specified user has access; otherwise, <c>false</c>.
        /// </returns>
        public bool HasAccess(ForumUser user, Permission.Rights right)
        {
            foreach (Forum forum in Forums)
            {
                if (forum.HasAccess(user, right))
                {
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 4
0
 private void SetupDefaultPermissions(int newId)
 {
     Hashtable permissions = GetPermissionsForForum(DEFAULT_FORUM_ID);
     IList<Group> groups = RepositoryRegistry.GroupRepository.GetAll();
     foreach (Group group in groups)
     {
         Permission perms = permissions[group.Id] as Permission;
         if (perms == null)
             perms = new Permission();
         SavePermissions(group.Id, newId, perms);
     }
 }
Exemplo n.º 5
0
 public int SavePermissions(int groupId, int forumId, Permission permission)
 {
     return _dao.SavePermissions(groupId, forumId, permission);
 }
Exemplo n.º 6
0
        public override void AddSampleData()
        {
            if (ListExists)
            {
                Permission perm = new Permission();
                string[] values = new string[6];

                perm.SetPermission(Permission.Rights.Read, true);
                values[0] = "Title";
                values[1] = perm.ToString();
                values[2] = "ForumID";
                values[3] = "1";
                values[4] = "GroupID";
                values[5] = "1"; // reader
                AddListValues(values);

                perm.SetPermission(Permission.Rights.Read, true);
                values[0] = "Title";
                values[1] = perm.ToString();
                values[2] = "ForumID";
                values[3] = "0"; // default (non-existant) forum
                values[4] = "GroupID";
                values[5] = "1"; // reader
                AddListValues(values);

                perm.SetPermission(Permission.Rights.Add, true);
                perm.SetPermission(Permission.Rights.Edit, true);
                perm.SetPermission(Permission.Rights.Reply, true);
                perm.SetPermission(Permission.Rights.Delete, true);
                values[0] = "Title";
                values[1] = perm.ToString();
                values[2] = "ForumID";
                values[3] = "1";
                values[4] = "GroupID";
                values[5] = "2"; // contributor
                AddListValues(values);

                perm.SetPermission(Permission.Rights.Add, true);
                perm.SetPermission(Permission.Rights.Edit, true);
                perm.SetPermission(Permission.Rights.Reply, true);
                perm.SetPermission(Permission.Rights.Delete, true);
                values[0] = "Title";
                values[1] = perm.ToString();
                values[2] = "ForumID";
                values[3] = "0"; // default forum
                values[4] = "GroupID";
                values[5] = "2"; // contributor
                AddListValues(values);

                perm.SetPermission(Permission.Rights.Admin, true);
                values[0] = "Title";
                values[1] = perm.ToString();
                values[2] = "ForumID";
                values[3] = "1";
                values[4] = "GroupID";
                values[5] = "3"; // administrator
                AddListValues(values);

                perm.SetPermission(Permission.Rights.Admin, true);
                values[0] = "Title";
                values[1] = perm.ToString();
                values[2] = "ForumID";
                values[3] = "0"; // default forum
                values[4] = "GroupID";
                values[5] = "3"; // administrator
                AddListValues(values);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Determines whether the specified user has access.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="rights">The rights.</param>
        /// <returns>
        /// 	<c>true</c> if the specified user has access; otherwise, <c>false</c>.
        /// </returns>
        public bool HasAccess(ForumUser user, Permission.Rights rights)
        {
            foreach (Group userGroup in user.Groups)
            {
                Permission perm = Permissions[userGroup.Id] as Permission;
                if (perm != null)
                {
                    if (perm.HasPermission(rights))
                        return true;
                }
            }

            return false;
        }