예제 #1
0
    private void Process_DoAddFolderPermission()
    {
        string[] userID = null;
        string[] groupID = null;
        int _userIDs = 0;
        int _grpIDs = 0;
        string @base = Request.Form[frm_base.UniqueID];
        string strUserID = "";
        string strGroupID = "";
        frm_itemid.Value = _Id.ToString();
        string finalUserGroupID = "";

        if (!string.IsNullOrEmpty(Request.QueryString["userIds"]))
        {
            userID = Request.QueryString["userIds"].Split(',');
            _userIDs = userID.Length;
        }
        if (!string.IsNullOrEmpty(Request.QueryString["groupIds"]))
        {
            groupID = Request.QueryString["groupIds"].Split(',');
            _grpIDs = groupID.Length;
        }
        if (_userIDs + _grpIDs == 1)
        {
            if (_userIDs == 1)
            {
                @base = "user";
                strUserID = Request.QueryString["userIds"];
            }
            else
            {
                @base = "group";
                strGroupID = Request.QueryString["groupIds"];
            }
        }
        string[] readOnlyPermission = Request.Form[frm_readonly.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] editPermission = Request.Form[frm_edit.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] addPermission = Request.Form[frm_add.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] deletePermission = Request.Form[frm_delete.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] readOnlyLibPermission = Request.Form[frm_libreadonly.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] addToImageLibPermission = Request.Form[frm_addimages.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] addToFileLibPermission = Request.Form[frm_addfiles.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] restorePermission = null;
        if (!(Request.Form[frm_restore.UniqueID] == null) && Request.Form[frm_restore.UniqueID] != "")
        {
            restorePermission = Request.Form[frm_restore.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        }
        string[] addToHyperlinkLibPermission = null;
        if (!(Request.Form[frm_addhyperlinks.UniqueID] == null) && Request.Form[frm_addhyperlinks.UniqueID] != "")
        {
            addToHyperlinkLibPermission = Request.Form[frm_addhyperlinks.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        }
        string[] overwriteLibPermission = null;
        if (!(Request.Form[frm_overwritelib.UniqueID] == null) && Request.Form[frm_overwritelib.UniqueID] != "")
        {
            overwriteLibPermission = Request.Form[frm_overwritelib.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        }
        string[] addFoldersPermission = Request.Form[frm_add_folders.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] editFoldersPermission = Request.Form[frm_edit_folders.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] deleteFoldersPermission = Request.Form[frm_delete_folders.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        string[] transverseFoldersPermission = null;
        if (!(Request.Form[frm_transverse_folder.UniqueID] == null) && Request.Form[frm_transverse_folder.UniqueID] != "")
        {
            transverseFoldersPermission = Request.Form[frm_transverse_folder.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        }
        string[] collectionsPermission = null;
        if (!(Request.Form[frm_navigation.UniqueID] == null) && Request.Form[frm_navigation.UniqueID] != "")
        {
            collectionsPermission = Request.Form[frm_navigation.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        }

        string[] editApprovalssPermission = null;
        if (!(Request.Form[frm_edit_preapproval.UniqueID] == null))
        {
            editApprovalssPermission = Request.Form[frm_edit_preapproval.UniqueID].Remove(0, 1).Split(",".ToCharArray());
        }

        switch (@base)
        {
            case "":
                int userCount = 0;

                string[] userGroupId = new string[_userIDs + (_grpIDs - 1) + 1];
                if (_grpIDs > 0 && _userIDs > 0)
                {
                    groupID.CopyTo(userGroupId, 0);
                    userID.CopyTo(userGroupId, groupID.Length);
                }
                else if (_grpIDs > 0)
                {
                    groupID.CopyTo(userGroupId, 0);
                }
                else
                {
                    userID.CopyTo(userGroupId, 0);
                }
                for (userCount = 0; userCount <= userGroupId.Length - 1; userCount++)
                {
                    _EkContent = _ContentApi.EkContentRef;
                    _PageData = new Collection();
                    if (Request.Form[hmembershiptype.UniqueID] == "1")
                    {
                        if ((readOnlyPermission[userCount] == "1") || readOnlyPermission[userCount].ToString().ToLower() == "on")
                        {
                            _PageData.Add(1, "ReadOnly", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnly", null, null);
                        }
                        if ((editPermission[userCount] == "1") || (editPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "Edit", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Edit", null, null);
                        }
                        if ((addPermission[userCount] == "1") || (addPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "Add", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Add", null, null);
                        }
                        if ((deletePermission[userCount] == "1") || (deletePermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "Delete", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Delete", null, null);
                        }
                        _PageData.Add(0, "Restore", null, null);
                        if ((readOnlyLibPermission[userCount] == "1") || (readOnlyLibPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "ReadOnlyLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnlyLib", null, null);
                        }
                        if ((addToImageLibPermission[userCount] == "1") || (addToImageLibPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "AddToImageLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToImageLib", null, null);
                        }
                        if ((addToFileLibPermission[userCount] == "1") || (addToFileLibPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "AddToFileLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToFileLib", null, null);
                        }
                        _PageData.Add(0, "AddToHyperlinkLib", null, null);
                        _PageData.Add(0, "OverwriteLib", null, null);
                        _PageData.Add(0, "AddFolders", null, null);
                        _PageData.Add(0, "EditFolders", null, null);
                        _PageData.Add(0, "DeleteFolders", null, null);
                        _PageData.Add(0, "Collections", null, null);
                        _PageData.Add(0, "TransverseFolder", null, null);
                        _PageData.Add(0, "EditApprovals", null, null);
                    }
                    else
                    {
                        if ((readOnlyPermission[userCount] == "1") || (readOnlyPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "ReadOnly", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnly", null, null);
                        }
                        if ((editPermission[userCount] == "1") || (editPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "Edit", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Edit", null, null);
                        }
                        if ((addPermission[userCount] == "1") || (addPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "Add", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Add", null, null);
                        }
                        if ((deletePermission[userCount] == "1") || (deletePermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "Delete", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Delete", null, null);
                        }
                        if (restorePermission != null && ((restorePermission[userCount] == "1") || (restorePermission[userCount].ToString().ToLower() == "on")))
                        {
                            _PageData.Add(1, "Restore", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Restore", null, null);
                        }
                        if ((readOnlyLibPermission[userCount] == "1") || (readOnlyLibPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "ReadOnlyLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnlyLib", null, null);
                        }
                        if ((addToImageLibPermission[userCount] == "1") || (addToImageLibPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "AddToImageLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToImageLib", null, null);
                        }
                        if ((addToFileLibPermission[userCount] == "1") || (addToFileLibPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "AddToFileLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToFileLib", null, null);
                        }
                        if (addToHyperlinkLibPermission != null && ((addToHyperlinkLibPermission[userCount] == "1") || (addToHyperlinkLibPermission[userCount].ToString().ToLower() == "on")))
                        {
                            _PageData.Add(1, "AddToHyperlinkLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToHyperlinkLib", null, null);
                        }
                        if (overwriteLibPermission != null && ((overwriteLibPermission[userCount] == "1") || (overwriteLibPermission[userCount].ToString().ToLower() == "on")))
                        {
                            _PageData.Add(1, "OverwriteLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "OverwriteLib", null, null);
                        }

                        if ((addFoldersPermission[userCount] == "1") || (addFoldersPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "AddFolders", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddFolders", null, null);
                        }
                        if ((editFoldersPermission[userCount] == "1") || (editFoldersPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "EditFolders", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "EditFolders", null, null);
                        }
                        if ((deleteFoldersPermission[userCount] == "1") || (deleteFoldersPermission[userCount].ToString().ToLower() == "on"))
                        {
                            _PageData.Add(1, "DeleteFolders", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "DeleteFolders", null, null);
                        }
                        if (transverseFoldersPermission != null && ((transverseFoldersPermission[userCount] == "1") || (transverseFoldersPermission[userCount].ToString().ToLower() == "on")))
                        {
                            _PageData.Add(1, "TransverseFolder", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "TransverseFolder", null, null);
                        }
                        if (collectionsPermission != null && ((collectionsPermission[userCount] == "1") || (collectionsPermission[userCount].ToString().ToLower() == "on")))
                        {
                            _PageData.Add(1, "Collections", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Collections", null, null);
                        }

                        if (!(editApprovalssPermission == null))
                        {
                            if ((editApprovalssPermission[userCount] == "1") || (editApprovalssPermission[userCount].ToString().ToLower() == "on"))
                            {
                                _PageData.Add(1, "EditApprovals", null, null);
                            }
                            else
                            {
                                _PageData.Add(0, "EditApprovals", null, null);
                            }
                        }
                        else
                        {
                            _PageData.Add(0, "EditApprovals", null, null);
                        }
                    }

                    if (Request.Form[frm_type.UniqueID] == "folder")
                    {
                        _PageData.Add(Request.Form[frm_itemid.UniqueID], "FolderID", null, null);
                        _PageData.Add("", "ContentID", null, null);
                    }
                    else
                    {
                        _PageData.Add(Request.Form[frm_itemid.UniqueID], "ContentID", null, null);
                        _PageData.Add("", "FolderID", null, null);
                    }
                    if (userCount < _grpIDs)
                    {
                        _PageData.Add(userGroupId[userCount], "UserGroupID", null, null);
                        _PageData.Add("", "UserID", null, null);
                    }
                    else
                    {
                        _PageData.Add(userGroupId[userCount], "UserID", null, null);
                        _PageData.Add("", "UserGroupID", null, null);
                    }
                    bool m_bReturn;
                    m_bReturn = _EkContent.AddItemPermission(_PageData);
                }
                Response.Redirect((string)("content.aspx?LangType=" + _ContentLanguage + "&action=ViewPermissions&id=" + Request.Form[frm_itemid.UniqueID] + "&type=" + Request.Form[frm_type.UniqueID] + "&membership=" + Request.Form[frm_membership.UniqueID]), false);
                break;

            default:
                try
                {
                    _EkContent = _ContentApi.EkContentRef;
                    _PageData = new Collection();
                    if (Request.Form[hmembershiptype.UniqueID] == "1")
                    {
                        if ((Request.Form["frm_readonly"] == "1") || Request.Form["frm_readonly"].ToString().ToLower() == "on")
                        {
                            _PageData.Add(1, "ReadOnly", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnly", null, null);
                        }
                        if (Request.Form[frm_edit.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Edit", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Edit", null, null);
                        }
                        if (Request.Form[frm_add.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Add", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Add", null, null);
                        }
                        if (Request.Form[frm_delete.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Delete", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Delete", null, null);
                        }
                        _PageData.Add(0, "Restore", null, null);
                        if (Request.Form[frm_libreadonly.UniqueID] == "1")
                        {
                            _PageData.Add(1, "ReadOnlyLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnlyLib", null, null);
                        }
                        if (Request.Form[frm_addimages.UniqueID] == "1")
                        {
                            _PageData.Add(1, "AddToImageLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToImageLib", null, null);
                        }
                        if (Request.Form[frm_addfiles.UniqueID] == "1")
                        {
                            _PageData.Add(1, "AddToFileLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToFileLib", null, null);
                        }
                        _PageData.Add(0, "AddToHyperlinkLib", null, null);
                        _PageData.Add(0, "OverwriteLib", null, null);
                        _PageData.Add(0, "AddFolders", null, null);
                        _PageData.Add(0, "EditFolders", null, null);
                        _PageData.Add(0, "DeleteFolders", null, null);
                        _PageData.Add(0, "Collections", null, null);
                        _PageData.Add(0, "TransverseFolder", null, null);
                        _PageData.Add(0, "EditApprovals", null, null);
                    }
                    else
                    {
                        if (Request.Form[frm_readonly.UniqueID] == "1")
                        {
                            _PageData.Add(1, "ReadOnly", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnly", null, null);
                        }
                        if (Request.Form[frm_edit.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Edit", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Edit", null, null);
                        }
                        if (Request.Form[frm_add.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Add", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Add", null, null);
                        }
                        if (Request.Form[frm_delete.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Delete", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Delete", null, null);
                        }
                        if (Request.Form[frm_restore.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Restore", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Restore", null, null);
                        }
                        if (Request.Form[frm_libreadonly.UniqueID] == "1")
                        {
                            _PageData.Add(1, "ReadOnlyLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "ReadOnlyLib", null, null);
                        }
                        if (Request.Form[frm_addimages.UniqueID] == "1")
                        {
                            _PageData.Add(1, "AddToImageLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToImageLib", null, null);
                        }
                        if (Request.Form[frm_addfiles.UniqueID] == "1")
                        {
                            _PageData.Add(1, "AddToFileLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToFileLib", null, null);
                        }
                        if (Request.Form[frm_addhyperlinks.UniqueID] == "1")
                        {
                            _PageData.Add(1, "AddToHyperlinkLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddToHyperlinkLib", null, null);
                        }
                        if (Request.Form[frm_overwritelib.UniqueID] == "1")
                        {
                            _PageData.Add(1, "OverwriteLib", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "OverwriteLib", null, null);
                        }

                        if (Request.Form[frm_add_folders.UniqueID] == "1")
                        {
                            _PageData.Add(1, "AddFolders", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "AddFolders", null, null);
                        }
                        if (Request.Form[frm_edit_folders.UniqueID] == "1")
                        {
                            _PageData.Add(1, "EditFolders", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "EditFolders", null, null);
                        }
                        if (Request.Form[frm_delete_folders.UniqueID] == "1")
                        {
                            _PageData.Add(1, "DeleteFolders", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "DeleteFolders", null, null);
                        }
                        if (Request.Form[frm_transverse_folder.UniqueID] == "1")
                        {
                            _PageData.Add(1, "TransverseFolder", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "TransverseFolder", null, null);
                        }
                        if (Request.Form[frm_navigation.UniqueID] == "1")
                        {
                            _PageData.Add(1, "Collections", null, null);
                        }
                        else
                        {
                            _PageData.Add(0, "Collections", null, null);
                        }

                        if (!(Request.Form[frm_edit_preapproval.UniqueID] == null))
                        {
                            if (Request.Form[frm_edit_preapproval.UniqueID] == "1")
                            {
                                _PageData.Add(1, "EditApprovals", null, null);
                            }
                            else
                            {
                                _PageData.Add(0, "EditApprovals", null, null);
                            }
                        }
                        else
                        {
                            _PageData.Add(0, "EditApprovals", null, null);
                        }
                    }

                    if (Request.Form[frm_type.UniqueID] == "folder")
                    {
                        _PageData.Add(Request.Form[frm_itemid.UniqueID], "FolderID", null, null);
                        _PageData.Add("", "ContentID", null, null);
                    }
                    else
                    {
                        _PageData.Add(Request.Form[frm_itemid.UniqueID], "ContentID", null, null);
                        _PageData.Add("", "FolderID", null, null);
                    }
                    if (Request.Form[frm_base.UniqueID] == "")
                    {
                        if (Request.QueryString["groupIds"] == "")
                        {
                            finalUserGroupID = strUserID;
                        }
                        else
                        {
                            finalUserGroupID = strGroupID;
                        }
                    }
                    else
                    {
                        finalUserGroupID = Request.Form[frm_permid.UniqueID];
                    }

                    if (Request.Form[frm_base.UniqueID] == "group")
                    {
                        _PageData.Add(finalUserGroupID, "UserGroupID", null, null);
                        _PageData.Add("", "UserID", null, null);
                    }
                    else if (Request.Form[frm_base.UniqueID] == "user")
                    {
                        _PageData.Add(finalUserGroupID, "UserID", null, null);
                        _PageData.Add("", "UserGroupID", null, null);
                    }
                    else if (Request.QueryString["groupIds"] != "")
                    {
                        _PageData.Add(finalUserGroupID, "UserGroupID", null, null);
                        _PageData.Add("", "UserID", null, null);
                    }
                    else if (Request.QueryString["userIds"] != "")
                    {
                        _PageData.Add(finalUserGroupID, "UserID", null, null);
                        _PageData.Add("", "UserGroupID", null, null);
                    }

                    bool m_bReturn;
                    m_bReturn = _EkContent.AddItemPermission(_PageData);
                    Response.Redirect((string)("content.aspx?LangType=" + _ContentLanguage + "&action=ViewPermissions&id=" + Request.Form[frm_itemid.UniqueID] + "&type=" + Request.Form[frm_type.UniqueID] + "&membership=" + Request.Form[frm_membership.UniqueID]), false);
                }
                catch (Exception ex)
                {
                    Response.Redirect((string)("reterror.aspx?info=" + EkFunctions.UrlEncode(ex.Message)), false);
                }
                break;
        }
    }