Can Admin Only Fields actually be Admin Only?

27 posts by 5 authors in: Forums > CMS Builder
Last Post: February 23, 2011   (RSS)

By zip222 - October 26, 2010

When setting up a section editor, you can specify for a field to be "Admin Only" - the problem is that this also includes Editors. Is there a way for it to actually be Admin Only?

Re: [zip222] Can Admin Only Fields actually be Admin Only?

By Jason - October 27, 2010

Hi Zip

You can do this by changing CMS Builder's code slightly.

Go into cmsAdmin/lib/menus/default/edit_functions.php

Part was down the page you'll see this code:

// special cases: skip fields if:
if (@$fieldHash['adminOnly'] && !$CURRENT_USER['isAdmin'] && !$GLOBALS['hasEditorAccess']) { continue; } // skip admin only fields


Change it to this:

// special cases: skip fields if:
if (@$fieldHash['adminOnly'] && !$CURRENT_USER['isAdmin'] ) { continue; } // skip admin only fields


This will mean that only admins can see the admin only fields. No editors will be able to view them in any section.
NOTE: If you upgrade CMS Builder, it will overwrite this change and you'll need to make it again.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Can Admin Only Fields actually be Admin Only?

By zip222 - October 27, 2010

Perfect. Thanks.

Re: [zip222] Can Admin Only Fields actually be Admin Only?

Are there any plans for this be an integrated option for a future release Jason?

I have plenty of instances where I need exactly this capability.

Kind regards

Paul

Re: [Pixels & Beats] Can Admin Only Fields actually be Admin Only?

By Jason - November 17, 2010

Hi Paul,

This is a feature that we'll consider for a future release.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Can Admin Only Fields actually be Admin Only?

Great news. Thanks for the update :)

Error occuring with above solution

By gadefgaertgqe - December 17, 2010 - edited: December 17, 2010

Hi peeps,

I am getting an error when trying to add a news record when the above solution is implemented. A screen shot of the error is attached to this message. The number at the end of the errors increments each time I try to save. It seems the record is actually created, and it does display in the website as intended.

Here is a copy of the schema for the only bit that is 'Admin Only' what I think is the offending section. The reason why I think that it's the offending section is the the default value is missing in the saved record.

[identify]
order = 6
label = "Identify"
type = "textfield"
adminOnly = 1
defaultValue = "dealer"
fieldPrefix = ""
description = ""
fieldWidth = ""
isPasswordField = 0
isRequired = 0
isUnique = 0
minLength = ""
maxLength = ""
charsetRule = ""
charset = ""

Any ideas?

Season Greetings.

Paul
Attachments:

error_004.gif 10K

Re: [Jason] Error occuring with above solution

Done. Many thanks Jason.

Re: [Pixels & Beats] Error occuring with above solution

For anyone else with this problem Jason kindly sorted this out for me. Here is his reply:

Hi Paul,

I got this working for you. You were right, because of the changed code, the default value and field name were not part of the $_REQUEST array. I added an "@" to line 335 (in: cmsAdmin/lib/menus/default/save.php) to suppress the warning. The only issue is that the default value won't be added to the database when added by a user that is not an administrator.

Hope this helps.
Jason




Thanks Jason!!