Help with Author settings

5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 9, 2011   (RSS)

By nmsinc - November 8, 2011

[font "Tahoma"]Setting users to “Author” should only allow the user to view and edit files they have created. Our design requires Authors to first create files in three distinct sections. These files are then used in three other distinct sections as a text field list where the user makes a choice from his/her records.[/#000000]

[/#000000]

Here is my dilemma:[/#000000]

[/#000000]

As the Author is creating a new record using the records from the other three sections, he/she can view and choose from all records created by all users and not just the ones he/she has created. [/#000000]

[/#000000]

What changes do I need to make to correct this so that the Author only sees his/her records as a choice?[/#000000]
nmsinc

Re: [nmsinc] Help with Author settings

By Jason - November 8, 2011

Hi,

What you can do is use a custom SQL string to populate your list box.

Try this,
When creating your list, for List Options select "Get options from MySQL Query (advanced)".

Here is an example of a query that will use "num" as the option value and "title'' as the option label from a section called "news". It will restrict options to only those created by the user currently logged in:

SELECT num, title
FROM `<?php echo $TABLE_PREFIX ?>news`
WHERE createdByUserNum = '<?php echo $CURRENT_USER['num'];?>'


Hope this helps get you started.
---------------------------------------------------
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: [nmsinc] Help with Author settings

By Jason - November 9, 2011

Hi,

Yes, that would stop editors from seeing everything.

Here is another approach. You can use PHP if statements to dynamically alter your sql query

NOTE: this example assumes that you are giving the user a permission level for ALL sections, not apply permissions one section at a time.

Try this:

<?php
$accessLevel = @$CURRENT_USER['accessList']['all']['accessLevel'];

$where = "";

if ($accessLevel == 6 || $accessLevel == 7) {
$where = "WHERE createdByUserNum = '".$CURRENT_USER['num']."'";
}

?>


SELECT num, title
FROM `<?php echo $TABLE_PREFIX ?>news`
<?php echo $where; ?>


If the logged in user is set to author or author & viewer, they will only see records they created as options. Otherwise, they'll see everything.

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] Help with Author settings

By nmsinc - November 9, 2011

Thanks Jason,

This worked perfect!
nmsinc