Some new code for you - prevent users changing advanced options when uploading image

This post has 4 Replies | 1 Follower

Top 500 Contributor
Posts 83
Points 900
ibrahimk Posted: Tue, May 9 2006 1:12 PM

I would love to post attached code but I can't (not enough priviledges) so here is steps to ensure that ONLY Gallery Administrators can change the items in the "Advanced Options" tab when uploading or editing a photo.

1. Beneath the following line of code in ControlPanel\Photos\PostEditControl.ascx.cs:

protected CommunityServer.ControlPanel.Controls.StatusMessage Status;

Add this field:

protected HtmlTable AdvancedProperties;

 

2. After the line

SetYesNo(post.PostConfig, post.IsApproved, !post.IsLocked, post.EnableAllOwnerNotification, post.EnableRatings, post.EnableTrackBacks, hasMultipleOwners);

Add the code:

if (!context.User.IsGalleryAdministrator) AdvancedProperties.Visible = false;

3. Finally, after the line

SetYesNo(CurrentGallery.DefaultPostConfig, true, true, false, this.CurrentGallery.EnableRatingsDefault, CurrentGallery.EnableTrackbacksDefault, false);

Add the code:

if (!context.User.IsGalleryAdministrator) AdvancedProperties.Visible = false;

 

Only users who are members of the Gallery Admins role will be able to specify advanced options when uploading or updating a picture.

 

  • | Post Points: 20
Not Ranked
Posts 10
Points 155
Abissum replied on Thu, May 11 2006 12:10 AM
Thank you, Ibrahim. Looks like it remained an open-source product, although not free of charge.
  • | Post Points: 20
Top 500 Contributor
Posts 83
Points 900
ibrahimk replied on Fri, May 12 2006 7:03 AM

There's more!!!

Owners of a gallery can change the gallery options such as "comment moderation", "enable ratings" etc etc.

To prevent non gallery admins from doing this:

1. Open ControlPanel\Photos\Options\PostOptions.aspx.cs

Add the following code anywhere in the file:

 

#region CODE ADDED BY SCOTT TUNSTALL

private void DisableOptions()

{

ynEnableReplies.Enabled=false;

ynEnableRatings.Enabled=false;

ynEnableTrackbacks.Enabled=false;

ynEnableOrderPrints.Enabled=false;

ynAggregatePost.Enabled=false;

ynCommunity.Enabled=false;

ynSyndicateExcerpt.Enabled=false;

ModerationDDL.Enabled=false;

ynEnableRepliesOverride.Enabled = false;

ynEnableRatingsOverride.Enabled=false;

ynEnableTrackbacksOverride.Enabled=false;

ynEnableOrderPrintsOverride.Enabled=false;

NotificationType.Enabled=false;

ModerationDDLOverride.Enabled=false;

ExpiredDays.Enabled=false;

}

#endregion

 

2. At the very end of the Page_Load method, add the following code:

CSContext context = CSContext.Current;

if (!context.User.IsGalleryAdministrator)

DisableOptions();

 

That's it. Now only Gallery Admins can change the settings for a gallery. Even the Owners cannot change these settings.

  • | Post Points: 35
Not Ranked
Posts 18
Points 255
skifreak replied on Sun, Oct 8 2006 12:50 AM

I must be too much of a noob with this but where is the Page_Load method and I'm not sure if

ControlPanel\Photos\Options\PostOptions.aspx

is the same as

ControlPanel\Photos\Options\PostOptions.aspx.cs


 

  • | Post Points: 5
Top 500 Contributor
Posts 64
Points 960

Hi Ibrahim, this is great!

Do you know a way to turn off the ability to delete photos, yet still be able to upload them, except the Gallery Admin? Lots of folks here would love to be able to do that. Smile

  • | Post Points: 5
Page 1 of 1 (5 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com