Пример #1
0
        /// <summary>
        /// Handles the OnAfterBindControl event of the wwDataBinder control.
        /// </summary>
        /// <param name="item">The wwDataBindingItem item.</param>
        protected void wwDataBinder_AfterBindControl(wwDataBindingItem item)
        {
            if (item.ControlInstance == txtPageSize)
            {
                int pageSize = Convert.ToInt32(this.txtPageSize.Text, CultureInfo.CurrentCulture);
                if (pageSize == 0)
                {
                    // Disable the checkbox because feature is turned off (a "0" indicates it is off). Set textbox to
                    // an empty string because we don't want to display 0.
                    chkEnablePaging.Checked = false;
                    txtPageSize.Text        = String.Empty;
                }
                else if (pageSize > 0)
                {
                    chkEnablePaging.Checked = true; // Select the checkbox when max # of items is > 0
                }
                else
                {
                    // We'll never get here because the config definition uses an IntegerValidator to force the number
                    // to be greater than 0.
                }
            }

            if (item.ControlInstance == lblLastAutoSync)
            {
                if (GallerySettings.LastAutoSync == DateTime.MinValue)
                {
                    lblLastAutoSync.Text = Resources.GalleryServer.Admin_Albums_LastAutoSync_Never_Lbl;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Handles the OnValidateControl event of the wwDataBinder control.
        /// </summary>
        /// <param name="item">The wwDataBindingItem item.</param>
        /// <returns>Returns <c>true</c> if the item is valid; otherwise returns <c>false</c>.</returns>
        protected bool wwDataBinder_ValidateControl(wwDataBindingItem item)
        {
            if (item.ControlInstance == txtMaxErrorItems)
            {
                if ((chkAutoTrimLog.Checked) && (Convert.ToInt32(txtMaxErrorItems.Text, CultureInfo.InvariantCulture) <= 0))
                {
                    item.BindingErrorMessage = Resources.GalleryServer.Admin_Error_Invalid_MaxNumberErrorItems_Msg;
                    return(false);
                }
            }

            if (item.ControlInstance == txtJQueryScriptPath)
            {
                if (!ValidateUrl(txtJQueryScriptPath.Text.Trim()))
                {
                    item.BindingErrorMessage = Resources.GalleryServer.Admin_Site_Settings_InvalidJQueryPath;
                    return(false);
                }
            }

            if (item.ControlInstance == txtJQueryUiScriptPath)
            {
                if (!ValidateUrl(txtJQueryUiScriptPath.Text.Trim()))
                {
                    item.BindingErrorMessage = Resources.GalleryServer.Admin_Site_Settings_InvalidJQueryPath;
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Handles the OnBeforeUnBindControl event of the wwDataBinder control.
        /// </summary>
        /// <param name="item">The wwDataBindingItem item.</param>
        protected bool wwDataBinder_BeforeUnbindControl(wwDataBindingItem item)
        {
            // When auto trim is disabled, we store "0" in the config table.
            if (!chkAutoTrimLog.Checked && item.ControlId == txtMaxErrorItems.ID)
            {
                txtMaxErrorItems.Text = "0";
            }

            if (item.ControlId == txtJQueryScriptPath.ID)
            {
                string url = txtJQueryScriptPath.Text.Trim();

                if (!String.IsNullOrEmpty(url) && !Utils.IsAbsoluteUrl(url) && (!url.StartsWith("~", StringComparison.Ordinal)))
                {
                    url = String.Concat("~", url); // Ensure relative URLs start with "~"
                }

                txtJQueryScriptPath.Text = url;
            }

            if (item.ControlId == txtJQueryUiScriptPath.ID)
            {
                string url = txtJQueryUiScriptPath.Text.Trim();

                if (!String.IsNullOrEmpty(url) && !Utils.IsAbsoluteUrl(url) && (!url.StartsWith("~", StringComparison.Ordinal)))
                {
                    url = String.Concat("~", url); // Ensure relative URLs start with "~"
                }

                txtJQueryUiScriptPath.Text = url;
            }

            return(true);
        }
Пример #4
0
        private bool BeforeUnbind_ProcessEnableSelfRegistrationControls(wwDataBindingItem item)
        {
            if (!this.chkEnableSelfRegistration.Checked)
            {
                // When self registration is unchecked, several child items are disabled via javascript. Disabled HTML items are not
                // posted during a postback, so we don't have accurate information about their states. For these controls don't save
                // anything by returning false. Furthermore, to prevent these child controls from incorrectly reverting to an
                // empty or unchecked state in the UI, assign their properties to their config setting.
                if (item.ControlId == this.chkRequireEmailValidation.ID)
                {
                    this.chkRequireEmailValidation.Checked = GallerySettings.RequireEmailValidationForSelfRegisteredUser;
                    return(false);
                }

                if (item.ControlId == this.chkRequireAdminApproval.ID)
                {
                    this.chkRequireAdminApproval.Checked = GallerySettings.RequireApprovalForSelfRegisteredUser;
                    return(false);
                }

                if (item.ControlId == this.chkUseEmailForAccountName.ID)
                {
                    this.chkUseEmailForAccountName.Checked = GallerySettings.UseEmailForAccountName;
                    return(false);
                }
            }

            return(true);
        }
Пример #5
0
        /// <summary>
        /// Handles the OnValidateControl event of the wwDataBinder control.
        /// </summary>
        /// <param name="item">The wwDataBindingItem item.</param>
        /// <returns>Returns <c>true</c> if the item is valid; otherwise returns <c>false</c>.</returns>
        protected bool wwDataBinder_ValidateControl(wwDataBindingItem item)
        {
            // Validate various settings to make sure they don't conflict with each other.

            if (item.ControlInstance == this.txtMoPath)
            {
                return(ValidateMediaObjectPath(item));
            }

            else if (item.ControlInstance == this.txtThumbnailCachePath)
            {
                return(ValidateThumbnailPath(item));
            }

            else if (item.ControlInstance == this.txtOptimizedCachePath)
            {
                return(ValidateOptimizedPath(item));
            }

            else if (item.ControlInstance == this.chkPathIsReadOnly)
            {
                return(ValidateMediaObjectPath(item)); // Validate the "media files are read-only" option
            }
            return(true);
        }
Пример #6
0
        private bool BeforeUnbind_ProcessEnableUserAlbumsControls(wwDataBindingItem item)
        {
            if (!this.chkEnableUserAlbums.Checked)
            {
                // When user albums is unchecked, several child items are disabled via javascript. Disabled HTML items are not
                // posted during a postback, so we don't have accurate information about their states. For these controls don't save
                // anything by returning false. Furthermore, to prevent these child controls from incorrectly reverting to an
                // empty or unchecked state in the UI, assign their properties to their config setting.
                if (item.ControlId == this.chkRedirectAfterLogin.ID)
                {
                    this.chkRedirectAfterLogin.Checked = GallerySettings.RedirectToUserAlbumAfterLogin;
                    return(false);
                }

                if (item.ControlId == this.txtAlbumNameTemplate.ID)
                {
                    this.txtAlbumNameTemplate.Text = GallerySettings.UserAlbumNameTemplate;
                    return(false);
                }

                if (item.ControlId == this.txtAlbumSummaryTemplate.ID)
                {
                    this.txtAlbumSummaryTemplate.Text = GallerySettings.UserAlbumSummaryTemplate;
                    return(false);
                }
            }

            return(true);
        }
Пример #7
0
        private bool ValidatePathIsWritable(wwDataBindingItem item, string fullPathToTest)
        {
            // Verify that the IIS process identity has write permission to the specified path.

            // We only need to execute this once for each unique path. If we already tested this path, then return that test result. This helps
            // prevent the same error message from being shown multiple times.
            if (_pathsThatHaveBeenTestedForWriteability.ContainsKey(fullPathToTest))
            {
                return(_pathsThatHaveBeenTestedForWriteability[fullPathToTest]);
            }

            bool isValid = false;

            try
            {
                HelperFunctions.ValidatePhysicalPathExistsAndIsReadWritable(fullPathToTest);
                isValid = true;
            }
            catch (CannotWriteToDirectoryException ex)
            {
                item.BindingErrorMessage = ex.Message;
            }

            // Set the flag so we don't have to repeat the validation later in the page lifecycle.
            _pathsThatHaveBeenTestedForWriteability.Add(fullPathToTest, isValid);

            return(isValid);
        }
Пример #8
0
        private static bool ValidatePathIsReadable(wwDataBindingItem item, string pathToTest, Label pathLabel)
        {
            // Verify that the IIS process identity has read permission to the specified path.
            bool isValid = false;

            string fullPhysicalPath = HelperFunctions.CalculateFullPath(AppSetting.Instance.PhysicalApplicationPath, pathToTest);

            try
            {
                HelperFunctions.ValidatePhysicalPathExistsAndIsReadable(fullPhysicalPath);
                isValid = true;
            }
            catch (CannotReadFromDirectoryException ex)
            {
                item.BindingErrorMessage = ex.Message;
            }

            if (isValid)
            {
                pathLabel.Text     = fullPhysicalPath;
                pathLabel.CssClass = "gsp_msgfriendly";
            }
            else
            {
                pathLabel.Text     = String.Concat("&lt;", Resources.GalleryServer.Admin_MediaObjects_InvalidPath, "&gt;");
                pathLabel.CssClass = "gsp_msgwarning";
            }

            return(isValid);
        }
Пример #9
0
        private bool ValidateUsersToNotifyWhenErrorOccurs(wwDataBindingItem item)
        {
            if ((item.ControlInstance == this.cboUsersToNotify))
            {
                string userNamesCurrent = String.Join(", ", GallerySettings.UsersToNotifyWhenErrorOccurs.GetUserNames());

                if ((!this.cboUsersToNotify.Text.Equals(userNamesCurrent)))
                {
                    // User has updated the list of users to notify. Make sure they represent valid user account names.
                    foreach (string userName in this.cboUsersToNotify.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        IUserAccount user = UserController.GetUser(Util.HtmlDecode(userName.Trim()), false);
                        if (user == null)
                        {
                            item.BindingErrorMessage = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Admin_General_Invalid_User_Name_Msg, userName.Trim());
                            return(false);
                        }

                        if (!HelperFunctions.IsValidEmail(user.Email))
                        {
                            item.BindingErrorMessage = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Admin_General_Invalid_User_Email_Msg, userName.Trim());
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Пример #10
0
        private bool ValidateUserAlbums(wwDataBindingItem item)
        {
            if ((item.ControlInstance == this.chkEnableUserAlbums) && (chkEnableUserAlbums.Checked))
            {
                // User albums are selected. Make sure this isn't a read-only gallery.
                if (GallerySettings.MediaObjectPathIsReadOnly)
                {
                    item.BindingErrorMessage = Resources.GalleryServerPro.Admin_User_Settings_Cannot_Enable_User_Albums_In_Read_Only_Gallery;
                    return(false);
                }
            }

            if ((item.ControlInstance == this.cboUserAlbumParent) && (chkEnableUserAlbums.Checked))
            {
                // User albums are selected. Make sure an album has been chosen to serve as the container for the user albums.
                int albumId;

                if ((tvUC.SelectedNode != null) && (Int32.TryParse(tvUC.SelectedNode.Value, out albumId)))
                {
                    return(true);
                }
                else
                {
                    item.BindingErrorMessage = Resources.GalleryServerPro.Admin_User_Settings_Invalid_UserAlbumParent_Msg;
                    return(false);
                }
            }

            return(true);
        }
Пример #11
0
 /// <summary>
 /// Handles the OnAfterBindControl event of the wwDataBinder control.
 /// </summary>
 /// <param name="item">The wwDataBindingItem item.</param>
 protected void wwDataBinder_AfterBindControl(wwDataBindingItem item)
 {
     // HTML encode the data
     if (item.ControlId == lblUserName.ID)
     {
         lblUserName.Text = Utils.HtmlEncode(lblUserName.Text);
     }
 }
Пример #12
0
        private bool ValidateThumbnailPath(wwDataBindingItem item)
        {
            string pathToTest = (String.IsNullOrEmpty(this.txtThumbnailCachePath.Text.Trim()) ? this.txtMoPath.Text.Trim() : this.txtThumbnailCachePath.Text.Trim());

            string fullPathToTest = HelperFunctions.CalculateFullPath(AppSetting.Instance.PhysicalApplicationPath, pathToTest);

            return(ValidatePath(item, fullPathToTest, this.lblThumbnailCachePath, DisplayObjectType.Thumbnail));
        }
Пример #13
0
        private bool ValidateUserCanEnableSelfRegistration(wwDataBindingItem item)
        {
            if ((item.ControlInstance == this.chkEnableSelfRegistration))
            {
                if (!UserCanEditUsersAndRoles)
                {
                    item.BindingErrorMessage = Resources.GalleryServerPro.Admin_User_Settings_Cannot_Enable_Self_Registration_Msg;
                    return(false);
                }
            }

            return(true);
        }
Пример #14
0
        /// <summary>
        /// Verify the roles in the DefaultRolesForSelfRegisteredUser setting exist. Returns false if one or more do not exist. The error
        /// message is assigned to the <see cref="wwDataBindingItem.BindingErrorMessage" /> property of <paramref name="item" />.
        /// </summary>
        /// <param name="item">The data binding item.</param>
        /// <returns>Returns true if every role in the DefaultRolesForSelfRegisteredUser setting exists; otherwise false.</returns>
        private bool VerifyDefaultRolesForSelfRegisteredUserExist(wwDataBindingItem item)
        {
            foreach (string roleName in GallerySettingsUpdateable.DefaultRolesForSelfRegisteredUser)
            {
                if (!RoleController.RoleExists(Util.HtmlDecode(roleName.Trim())))
                {
                    item.BindingErrorMessage = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Admin_User_Settings_Invalid_Role_Name_Msg, roleName);
                    return(false);
                }
            }

            return(true);
        }
Пример #15
0
        private bool ValidateReadOnlyGallery(wwDataBindingItem item)
        {
            // When a gallery is read only, the following must be true:
            // 1. The thumbnail and optimized path must be different than the media object path.
            // 2. The SynchAlbumTitleAndDirectoryName setting must be false.
            // 3. User albums must be disabled.

            // We only need to execute this once on a postback. If we already ran it, then return our previous result. This helps
            // prevent the same error message from being shown multiple times.
            if (_validateReadOnlyGalleryHasExecuted)
            {
                return(_validateReadOnlyGalleryResult);
            }

            bool isValid = true;

            string mediaObjectPath = this.txtMoPath.Text;
            string thumbnailPath   = (String.IsNullOrEmpty(this.txtThumbnailCachePath.Text) ? mediaObjectPath : this.txtThumbnailCachePath.Text);
            string optimizedPath   = (String.IsNullOrEmpty(this.txtOptimizedCachePath.Text) ? mediaObjectPath : this.txtOptimizedCachePath.Text);

            // 1. The thumbnail and optimized path must be different than the media object path.
            if ((mediaObjectPath.Equals(thumbnailPath, StringComparison.OrdinalIgnoreCase)) ||
                (mediaObjectPath.Equals(optimizedPath, StringComparison.OrdinalIgnoreCase)))
            {
                isValid = false;
                item.BindingErrorMessage = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServer.Admin_MediaObjects_Cannot_Set_MO_Path_Read_Only_Cache_Location_Not_Set, mediaObjectPath, thumbnailPath, optimizedPath);
            }

            // 2. The SynchAlbumTitleAndDirectoryName setting must be false.
            if (chkSynchAlbumTitleAndDirectoryName.Checked)
            {
                isValid = false;
                item.BindingErrorMessage = Resources.GalleryServer.Admin_MediaObjects_Cannot_Set_MO_Path_Read_Only_Synch_Title_And_Directory_Enabled;
            }

            // 3. User albums must be disabled.
            if (GallerySettings.EnableUserAlbum)
            {
                isValid = false;
                item.BindingErrorMessage = Resources.GalleryServer.Admin_MediaObjects_Cannot_Set_MO_Path_Read_Only_User_Albums_Enabled;
            }

            // Set the flag so we don't have to repeat the validation later in the page lifecycle.
            this._validateReadOnlyGalleryHasExecuted = true;
            this._validateReadOnlyGalleryResult      = isValid;

            return(isValid);
        }
Пример #16
0
        private bool BeforeUnbind_ProcessUserAccountControls(wwDataBindingItem item)
        {
            // When allow HTML is unchecked, several child items are disabled via javascript. Disabled HTML items are not
            // posted during a postback, so we don't have accurate information about their states. For these controls don't save
            // anything by returning false. Furthermore, to prevent these child controls from incorrectly reverting to an
            // empty or unchecked state in the UI, assign their properties to their config setting.

            // Step 1: Handle the "allow HTML" checkbox
            if (!chkAllowHtml.Checked)
            {
                if (item.ControlId == txtAllowedHtmlTags.ID)
                {
                    txtAllowedHtmlTags.Text = AllowedHtmlTags;
                    return(false);
                }

                if (item.ControlId == txtAllowedHtmlAttributes.ID)
                {
                    txtAllowedHtmlAttributes.Text = AllowedHtmlAttributes;
                    return(false);
                }
            }
            else
            {
                // User may have hit Return while editing one of the textboxes. Remove any return characters to be safe.
                if (item.ControlId == txtAllowedHtmlTags.ID)
                {
                    txtAllowedHtmlTags.Text = txtAllowedHtmlTags.Text.Replace("\r\n", String.Empty);
                }

                if (item.ControlId == txtAllowedHtmlAttributes.ID)
                {
                    txtAllowedHtmlAttributes.Text = txtAllowedHtmlAttributes.Text.Replace("\r\n", String.Empty);
                }
            }

            // Step 2: Handle the "allow user account management" checkbox
            if (!this.chkAllowManageAccount.Checked)
            {
                if (item.ControlId == this.chkAllowDeleteOwnAccount.ID)
                {
                    this.chkAllowDeleteOwnAccount.Checked = GallerySettingsUpdateable.AllowDeleteOwnAccount;
                    return(false);
                }
            }

            return(true);
        }
Пример #17
0
 private bool ValidateUsersToNotifyWhenAccountIsCreated(wwDataBindingItem item)
 {
     if ((item.ControlInstance == this.cboUsersToNotify) && (this.cboUsersToNotify.Text != Core.UsersToNotifyWhenAccountIsCreated))
     {
         // User has updated the list of users to notify. Make sure they represent valid user account names.
         foreach (string userName in this.cboUsersToNotify.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
         {
             if (UserController.GetUser(Util.HtmlDecode(userName), false) == null)
             {
                 item.BindingErrorMessage = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Admin_User_Settings_Invalid_User_Name_Msg, userName);
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #18
0
 private bool ValidateDefaultRolesForSelfRegisteredUser(wwDataBindingItem item)
 {
     if ((item.ControlInstance == this.cboUserRoles) && (this.cboUserRoles.Text != Core.DefaultRolesForSelfRegisteredUser))
     {
         // User has updated the list of default roles. Make sure they represent valid roles.
         foreach (string roleName in this.cboUserRoles.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
         {
             if (!RoleController.RoleExists(Util.HtmlDecode(roleName.Trim())))
             {
                 item.BindingErrorMessage = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Admin_User_Settings_Invalid_Role_Name_Msg, roleName);
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #19
0
        /// <summary>
        /// Verifies the <paramref name="fullPathToTest" /> is valid and the logged-on user has the necessary permission to specify it.
        /// </summary>
        /// <param name="item">The binding item representing the control being tested.</param>
        /// <param name="fullPathToTest">The full file path the user wishes to use to store media objects, whether they are
        /// the original media object files, thumbnails, or optimized image files.
        /// Examples: "C:\inetpub\wwwroot\galleryserverpro\myimages\", "C:/inetpub/wwwroot/galleryserverpro/myimages"</param>
        /// <param name="pathDisplayControl">The Label control used to display the full, calculated path.</param>
        /// <param name="displayType">Indicates whether the <paramref name="fullPathToTest" /> is the path for the original, thumbnail,
        /// or optimized media object files.</param>
        /// <returns>
        /// Returns <c>true</c> if the path is valid; otherwise returns <c>false</c>.
        /// </returns>
        private bool ValidatePath(wwDataBindingItem item, string fullPathToTest, Label pathDisplayControl, DisplayObjectType displayType)
        {
            if (_validatePathFailed)
            {
                // To help prevent repeated error messages (one each for original, thumbnail, and optimized), if a previous execution of
                // this test has failed, then let's just return true, thus allowing the user to focus on a single message.
                return(true);
            }

            bool isValid;

            if (this.chkPathIsReadOnly.Checked)
            {
                if (displayType == DisplayObjectType.Original)
                {
                    isValid = ValidateReadOnlyGallery(item) && ValidatePathIsReadable(item, fullPathToTest, pathDisplayControl);
                }
                else
                {
                    isValid = ValidateReadOnlyGallery(item) && ValidatePathIsWritable(item, fullPathToTest);
                }
            }
            else
            {
                isValid = ValidatePathIsWritable(item, fullPathToTest);
            }

            isValid = isValid && ValidateUserHasPermissionToSpecifyPath(item, fullPathToTest);

            if (isValid)
            {
                pathDisplayControl.Text     = fullPathToTest;
                pathDisplayControl.CssClass = "gsp_msgfriendly";
            }
            else
            {
                if (!this.GallerySettings.FullMediaObjectPath.Equals(fullPathToTest, StringComparison.OrdinalIgnoreCase))
                {
                    pathDisplayControl.Text     = String.Concat("&lt;", Resources.GalleryServerPro.Admin_MediaObjects_InvalidPath, "&gt;");
                    pathDisplayControl.CssClass = "gsp_msgwarning";
                }
                _validatePathFailed = true;
            }

            return(isValid);
        }
Пример #20
0
        private bool BeforeUnbind_ProcessDisplayBehaviorControls(wwDataBindingItem item)
        {
            // When allow HTML is unchecked, several child items are disabled via javascript. Disabled HTML items are not
            // posted during a postback, so we don't have accurate information about their states. For these controls don't save
            // anything by returning false. Furthermore, to prevent these child controls from incorrectly reverting to an
            // empty or unchecked state in the UI, assign their properties to their config setting.

            if (!this.chkShowHeader.Checked)
            {
                if (item.ControlId == this.txtWebsiteTitle.ID)
                {
                    txtWebsiteTitle.Text = GallerySettingsUpdateable.GalleryTitle;
                    return(false);
                }

                if (item.ControlId == this.txtWebsiteTitleUrl.ID)
                {
                    txtWebsiteTitleUrl.Text = GallerySettingsUpdateable.GalleryTitleUrl;
                    return(false);
                }

                if (item.ControlId == this.chkShowLogin.ID)
                {
                    this.chkShowLogin.Checked = GallerySettingsUpdateable.ShowLogin;
                    return(false);
                }

                if (item.ControlId == this.chkShowSearch.ID)
                {
                    this.chkShowSearch.Checked = GallerySettingsUpdateable.ShowSearch;
                    return(false);
                }
            }

            if (!this.chkSendEmail.Checked)
            {
                if (item.ControlId == this.cboUsersToNotify.ID)
                {
                    cboUsersToNotify.Text = String.Empty;
                    return(false);
                }
            }
            return(true);
        }
Пример #21
0
        private bool ValidateUserCanEnableSelfRegistration(wwDataBindingItem item)
        {
            if ((item.ControlInstance == this.chkEnableSelfRegistration))
            {
                if (!UserCanEditUsersAndRoles)
                {
                    item.BindingErrorMessage = Resources.GalleryServer.Admin_User_Settings_Cannot_Enable_Self_Registration_Msg;
                    return(false);
                }

                if (this.chkEnableSelfRegistration.Checked && this.chkRequireAdminApproval.Checked && this.lbUsersToNotify.SelectedItem == null)
                {
                    wwDataBinder.AddBindingError("Admin approval for new accounts requires specifying at least one administrator in the new account notification setting in the User Permissions section. Either turn off admin approval or select one or more administrators to be notified.", chkRequireAdminApproval);
                    return(false);
                }
            }

            return(true);
        }
Пример #22
0
        /// <summary>
        /// Handles the OnBeforeUnBindControl event of the wwDataBinder control.
        /// </summary>
        /// <param name="item">The wwDataBindingItem item.</param>
        protected bool wwDataBinder_BeforeUnbindControl(wwDataBindingItem item)
        {
            if (!this.chkEnablePaging.Checked)
            {
                // When paging is disabled, we store "0" in the config file.
                if (item.ControlId == this.txtPageSize.ID)
                {
                    txtPageSize.Text = "0";
                    return(true); // true indicates that we want to save this setting
                }

                // Disabled HTML items are not posted during a postback, so we don't have accurate information about their states.
                // Look for the checkboxes that cause other controls to be disabled, and assign the value of the disabled control to their
                // database setting. This allows disabled controls to retain their original value if an admin later re-enables them.
                if (item.ControlId == this.ddlPagerLocation.ID)
                {
                    this.ddlPagerLocation.SelectedValue = GallerySettingsUpdateable.PagerLocation.ToString();
                    return(false);
                }
            }

            if (!this.chkEnableAutoSync.Checked)
            {
                // When the auto-sync feature is unchecked, the interval textbox is disabled via javascript.
                if (item.ControlId == this.txtAutoSyncIntervalMinutes.ID)
                {
                    this.txtAutoSyncIntervalMinutes.Text = GallerySettings.AutoSyncIntervalMinutes.ToString(CultureInfo.CurrentCulture);
                    return(false);
                }
            }

            if (!this.chkEnableRemoteSync.Checked)
            {
                // When the remote sync feature is unchecked, the remote access password textbox is disabled via javascript.
                if (item.ControlId == this.txtRemoteAccessPassword.ID)
                {
                    this.txtRemoteAccessPassword.Text = GallerySettings.RemoteAccessPassword;
                    return(false);
                }
            }

            return(true);
        }
Пример #23
0
        /// <summary>
        /// Verifies the currently logged-on user has permission to specify the <paramref name="mediaObjectPath"/> in this gallery. The
        /// path must not be used by any other galleries unless the user is a gallery admin for each of those galleries or a site
        /// admin. Returns <c>true</c> if the user has permission; otherwise returns <c>false</c>.
        /// </summary>
        /// <param name="item">The binding item representing the control being tested.</param>
        /// <param name="mediaObjectPath">The relative or full file path the user wishes to use to store media objects, whether they are
        /// the original media object files, thumbnails, or optimized image files. Relative paths should be relative
        /// to the root of the running application so that, when it is combined with physicalAppPath parameter, it creates a valid path.
        /// Examples: "C:\inetpub\wwwroot\galleryserverpro\myimages\", "C:/inetpub/wwwroot/galleryserverpro/myimages",
        /// "\myimages\", "\myimages", "myimages\", "myimages",	"/myimages/", "/myimages"</param>
        /// <returns>
        /// Returns <c>true</c> if the user has permission; otherwise returns <c>false</c>.
        /// </returns>
        private bool ValidateUserHasPermissionToSpecifyPath(wwDataBindingItem item, string mediaObjectPath)
        {
            if (UserCanAdministerSite)
            {
                return(true); // Site admins always have permission.
            }
            if (!UserCanAdministerGallery)
            {
                return(false); // Must be at least a gallery admin. Kind of a redundant test but we include it for extra safety.
            }
            string fullMediaObjectPath = HelperFunctions.CalculateFullPath(AppSetting.Instance.PhysicalApplicationPath, mediaObjectPath);

            bool isValid = true;

            // Get a list of galleries the current user is a gallery admin for.
            IGalleryCollection adminGalleries = UserController.GetGalleriesCurrentUserCanAdminister();

            // Iterate through each gallery and check to see if the path is used in it.
            foreach (IGallery gallery in Factory.LoadGalleries())
            {
                if (gallery.GalleryId == GalleryId)
                {
                    continue; // No need to evaluate the current gallery
                }
                IGallerySettings gallerySettings = Factory.LoadGallerySetting(gallery.GalleryId);

                if ((fullMediaObjectPath.Equals(gallerySettings.FullMediaObjectPath, StringComparison.OrdinalIgnoreCase)) ||
                    (fullMediaObjectPath.Equals(gallerySettings.FullThumbnailPath, StringComparison.OrdinalIgnoreCase)) ||
                    (fullMediaObjectPath.Equals(gallerySettings.FullOptimizedPath, StringComparison.OrdinalIgnoreCase)))
                {
                    // We found another gallery that is using this path. This is not valid unless the user is a gallery admin for it.
                    if (!adminGalleries.Contains(gallery))
                    {
                        isValid = false;
                        item.BindingErrorMessage = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServer.Admin_MediaObjects_MO_Path_Used_By_Another_Gallery, mediaObjectPath);
                    }
                }
            }

            return(isValid);
        }
Пример #24
0
        /// <summary>
        /// Handles the OnValidateControl event of the wwDataBinder control.
        /// </summary>
        /// <param name="item">The wwDataBindingItem item.</param>
        /// <returns>Returns <c>true</c> if the item is valid; otherwise returns <c>false</c>.</returns>
        protected bool wwDataBinder_ValidateControl(wwDataBindingItem item)
        {
            if (item.ControlInstance == txtPageSize)
            {
                if ((chkEnablePaging.Checked) && (Convert.ToInt32(txtPageSize.Text, CultureInfo.CurrentCulture) <= 0))
                {
                    item.BindingErrorMessage = Resources.GalleryServer.Admin_Error_Invalid_PageSize_Msg;
                    return(false);
                }
            }

            if (item.ControlInstance == txtRemoteAccessPassword)
            {
                if (chkEnableRemoteSync.Checked && String.IsNullOrEmpty(txtRemoteAccessPassword.Text))
                {
                    item.BindingErrorMessage = Resources.GalleryServer.Admin_Albums_RemoteAccessPassword_Required_Msg;
                    return(false);
                }
            }

            return(true);
        }
Пример #25
0
        private bool ValidateDefaultRolesForSelfRegisteredUser(wwDataBindingItem item)
        {
            if ((item.ControlInstance == this.cboUserRoles))
            {
                string roleNames = String.Join(", ", GallerySettings.DefaultRolesForSelfRegisteredUser);

                if ((!this.cboUserRoles.Text.Equals(roleNames)))
                {
                    // User has updated the list of default roles. Validate.
                    if (!VerifyDefaultRolesForSelfRegisteredUserExist(item))
                    {
                        return(false);
                    }

                    if (!VerifyUserHasPermissionToAddUserToDefaultRolesForSelfRegisteredUser(item))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #26
0
 /// <summary>
 /// Handles the OnAfterBindControl event of the wwDataBinder control.
 /// </summary>
 /// <param name="item">The wwDataBindingItem item.</param>
 protected void wwDataBinder_AfterBindControl(wwDataBindingItem item)
 {
     //
     if (item.ControlInstance == txtMaxErrorItems)
     {
         int maxErrorItems = Convert.ToInt32(this.txtMaxErrorItems.Text, CultureInfo.InvariantCulture);
         if (maxErrorItems == 0)
         {
             // Disable the checkbox because feature is turned off (a "0" indicates it is off). Set textbox to
             // an empty string because we don't want to display 0.
             chkAutoTrimLog.Checked = false;
             txtMaxErrorItems.Text  = String.Empty;
         }
         else if (maxErrorItems > 0)
         {
             chkAutoTrimLog.Checked = true; // Select the checkbox when max # of items is > 0
         }
         else
         {
             // We'll never get here because the config definition uses an IntegerValidator to force the number
             // to be greater than 0.
         }
     }
 }
Пример #27
0
 /// <summary>
 /// Handles the OnValidateControl event of the wwDataBinder control.
 /// </summary>
 /// <param name="item">The wwDataBindingItem item.</param>
 /// <returns>Returns <c>true</c> if the item is valid; otherwise returns <c>false</c>.</returns>
 protected bool wwDataBinder_ValidateControl(wwDataBindingItem item)
 {
     // Validate various settings to make sure they don't conflict with each other.
     return(true);
 }
Пример #28
0
        /// <summary>
        /// Verifies the logged on user has permission to add users to the roles defined in the DefaultRolesForSelfRegisteredUser setting.
        /// </summary>
        /// <param name="item">The data binding item.</param>
        /// <returns>Returns true if logged on user has permission to add users to the roles defined in the DefaultRolesForSelfRegisteredUser setting;
        /// otherwise false.</returns>
        private bool VerifyUserHasPermissionToAddUserToDefaultRolesForSelfRegisteredUser(wwDataBindingItem item)
        {
            IUserAccount sampleNewUser = new UserAccount(Guid.NewGuid().ToString());

            try
            {
                UserController.ValidateLoggedOnUserHasPermissionToSaveUser(sampleNewUser, GallerySettingsUpdateable.DefaultRolesForSelfRegisteredUser, null);
            }
            catch (GallerySecurityException ex)
            {
                item.BindingErrorMessage = ex.Message;
                return(false);
            }
            return(true);
        }
Пример #29
0
        private bool ValidateMediaObjectPath(wwDataBindingItem item)
        {
            string fullPathToTest = HelperFunctions.CalculateFullPath(AppSetting.Instance.PhysicalApplicationPath, this.txtMoPath.Text.Trim());

            return(ValidatePath(item, fullPathToTest, this.lblMoPath, DisplayObjectType.Original));
        }