Ejemplo n.º 1
0
        /// <summary>
        /// Sets the ifolder synchronization status on all selected ifolders.
        /// </summary>
        /// <param name="syncStatus">If true then all selected ifolders will be enabled.</param>
        private void SetSelectediFolderStatus(bool syncStatus)
        {
            foreach (string ifolderID in CheckediFolders.Keys)
            {
                /// Check for rights...
                int preference = GetRightsForiFolder(ifolderID);
                if (preference == -1)
                {
                    preference = 0xffff;
                }
                UserGroupAdminRights rights = new UserGroupAdminRights((int)preference);
                if (!rights.EnableDisableiFolderAllowed)
                {
                    continue;
                }
                // Don't set the status if already set.
                if (CheckediFolders[ifolderID] as string != syncStatus.ToString())
                {
                    iFolderPolicy policy = Utils.GetiFolderPolicyObject(ifolderID);
                    policy.Locked = syncStatus;
                    string     ifolderLocation = web.GetiFolderLocation(ifolderID);
                    UriBuilder remoteurl       = new UriBuilder(ifolderLocation);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();

                    try
                    {
                        web.SetiFolderPolicy(policy);
                    }
                    catch (Exception ex)
                    {
                        TopNav.ShowError(GetString("ERRORCANNOTSETIFOLDERSTATUS"), ex);
                        web.Url = currentServerURL;
                        return;
                    }
                }
            }

            // Clear the checked members.
            CheckediFolders.Clear();
            AlliFoldersCheckBox.Checked = false;

            // Set the action buttons.
            SetActionButtons();
            web.Url = currentServerURL;

            // Rebind the data source with the new data.
            GetiFolders();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Event handler that gets called with the delete ifolder button is clicked.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void OnDeleteButton_Click(object source, EventArgs e)
        {
            string skippediFolderNames = "";

            foreach (string ifolderID in CheckediFolders.Keys)
            {
                try
                {
                    int rights = GetRightsForiFolder(ifolderID);
                    if (rights == -1)
                    {
                        rights = 0xffff;
                    }

                    UserGroupAdminRights adminRights = new UserGroupAdminRights(rights);
                    string ownerID = GetiFolderOwnerID(ifolderID);

                    /*Condition for skipping iFolders for deletion. We allow the owner to
                     * delete his own iFolder. */
                    if (userID != ownerID)
                    {
                        if (!adminRights.DeleteiFolderAllowed)
                        {
                            string ifolderName = GetiFolderName(ifolderID);
                            if (skippediFolderNames.Length > 0)                      //Just for adding a comma.
                            {
                                skippediFolderNames += ", " + ifolderName;
                            }
                            else
                            {
                                skippediFolderNames += ifolderName;
                            }

                            continue;
                        }
                    }

                    string     ifolderLocation = web.GetiFolderLocation(ifolderID);
                    UriBuilder remoteurl       = new UriBuilder(ifolderLocation);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();

                    web.DeleteiFolder(ifolderID);
                }
                catch (Exception ex)
                {
                    TopNav.ShowError(GetString("ERRORCANNOTDELETEIFOLDER"), ex);
                    web.Url = currentServerURL;
                    return;
                }
            }
            web.Url = currentServerURL;

            // Clear the checked members.
            CheckediFolders.Clear();
            AlliFoldersCheckBox.Checked = false;

            // Set the action buttons.
            SetActionButtons();

            // Rebind the data source with the new data.
            GetiFolders();

            //If we have skipped some iFolders, tell the admin.
            if (skippediFolderNames.Length > 0)
            {
                TopNav.ShowError(string.Format(GetString("ERRORCANNOTDELETEIFOLDER"), skippediFolderNames));
            }
        }