Profile Rows Table

16 views
Skip to first unread message

Anderson Florencio

unread,
Dec 16, 2015, 7:24:35 AM12/16/15
to ZnetDK
Hello Pascal, here I again, hehehe. I have a question related to issue permits. I saw in the ZnetDK table structure he has a table called zdk_profile_rows, and saw that this table is related to the user view filter on a particular datatable.
I wonder if this is already implemented, and if you would like an example? thank you

Pascal Martinez

unread,
Dec 17, 2015, 4:21:31 PM12/17/15
to ZnetDK
Hello Anderson,

Yes, ZnetDK includes the capability to limit the access to SQL table rows according to the specified user profiles, through the call to the DAO::setStoredProfiles() and DAO::setProfileCriteria() methods.

When you store a row in a SQL table, you can call first the DAO::setStoredProfiles() to specify the user profile(s) authorized to access to the table row (these infos are stored in the zdk_profile_rows table). 

$row = array('id'=>18,'name'=>'MARTIN','city'=>'Paris');
$myDao
= new \app\model\Customers();
$myDao
->setStoredProfiles(array('Buyer'));
$result
= $myDao->store($row);

Next, when you request table rows through a call to the DAO::getResult() method, first call the DAO::setProfileCriteria() method to limit the returned rows to those matching the specified user profiles.

$myDao = new \app\model\Customers();
$myDao
->setProfileCriteria(array('Accountant','Manager'));
while($row = $myDao->getResult()) {
    $customers
[] = $row['id'];
}

To check whether the connected user gets a given profile, call the \controller\Users:hasProfile() method:

if (\controller\Users:hasProfile('Administrator') {
    echo
'The connected user is an Administrator';
} else {
    echo
'The connected user is not an Administrator';
}

Hoping it will help you

Regards,
Reply all
Reply to author
Forward
0 new messages