List Access Setup "How to"?

Status
Not open for further replies.

rackem

Well-Known Member
I am wondering how to achieve a certain type of list access setup.

I have a pool player rating system that allows users to enter their own rating/vote on a list of players. Right now "players" can be added/edited by any registered users. However, in the case that a user has entered themselves as a player, I would like to give them sole edit privileges. An admin user would go in and select what user would have that right per player if any.

I can't just change the "or use field" option to be "user" in my list settings as the ACL for "Edit Records" is set to Registered so that would take precedence. I thought about using a calc element that would equal the user id when the "player" should only be editable by the one user and then "foo" when the "player" should be editable by anyone. But I don't know what "foo" could possibly be to make this work. It would have to somehow be an array of all the registered users I think?

Any suggestions or is this currently possible?
 
Have a look at the "caneditrow" list plugin.
You can check against an element or do your own PHP code.
 
Awesome, that will do nicely! :D

So I set my list's edit access to "Registered & Admin". I created a dbjoin element to my #_user table that my admin uses to select which user "owns" which player. Then I used the following code in the "CanEditRow" list plugin:

$user =& JFactory::getUser(); // gets a user object
$me = $user->id; // gets the user id
$pwr = in_array(11,$user->getAuthorisedGroups()); // determines if the user is part of group id 11
$own = '{mps_players___owner_raw}'; // element that contains the player's "owner"

if($pwr) return TRUE;
elseif($own <> 0 AND $own <> $me) return FALSE;
else return TRUE;

So if a user is an admin (which is my group id# 11), they can edit any player. Registered users can edit all players unless that player is "owned" by another user. Users can edit players that they "own".
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top