This project is read-only.

Disable post publish for editors

Topics: Controls
Apr 7, 2009 at 10:05 AM
I have writers who I'd like to be able to add articles but not to publish - (set article live), is there a simple way to do this without having to create a copy of ../admin/Pages/Add_entry.aspx with the publish field hidden and unchecked.
Apr 7, 2009 at 7:07 PM
In the Add_entry.aspx.cs file, you could add code to make the 'published' checkbox invisible depending on who is (or isn't) on the page.

As an example, in the Page_Load event, the code you could add would be ...

1. Right after BindDrafts(), add:

bool canPublish = true;

if (Page.User.Identity.Name == "John")
    canPublish = false;

2. Right after BindBookmarklet(), add:

if (!canPublish)
    cbPublish.Checked = false;

3. Right after "ddlAuthor.Enabled = false", add:

if (!canPublish)
    cbPublish.Visible = false;
Apr 8, 2009 at 5:00 AM
I tried that and get the following error.

Source Error:

Line 28: 			BindDrafts();
Line 29: 			if (Page.User.Identity.Name == "editor")
Line 30: canPublish = false;Line 31: 
Line 32: 			Page.Title = Resources.labels.add_Entry;

Source File: c:\websites\BlogEngine\BlogEngine.Web\admin\Pages\Add_entry.aspx.cs    Line: 30 
Apr 8, 2009 at 5:07 AM
Did you put the first line in?

bool canPublish = true;

If that's not the problem and there's any more error information, please post that.
Apr 8, 2009 at 5:26 AM
I must have missed that line and that works now. I do however have the issue with the user who posted the story - i'll call him A (with no publish rights) being the only one able to edit the story. User B with full rights doesnt seem to be able to edit it at all. I there for cannot post the article live for the general public to see in any way. Can you help?
Apr 8, 2009 at 5:29 AM
The workaround I have found for this is to log in as USER A change ownnership to USER B and then login again as USER B with ability to publish. A bit convoluted though.
Apr 8, 2009 at 5:36 AM
Actually I can get around all of this by using Live Writer and take ownership from there. It actually now works well with editors working from web GUI and me approving by Livewriter. Thanks for your help BenAmada
Apr 8, 2009 at 6:30 PM
Edited Apr 8, 2009 at 6:30 PM
Was just thinking it might be better to do a case-insensitive check of the logged in person's name.  It's possible if they log in typing "Editor" (rather than "editor"), there name might come through as they typed it.  A case-insensitive check can be done as shown below (this would replace the line you currently have):

if (Page.User.Identity.Name.Equals("editor", StringComparison.OrdinalIgnoreCase))
    canPublish = false;