i would like explain some things before i start post this topic
on AppGini there Are users and Group i understand this very well
lets say in my App there are three Group
1- Admin ( administrator )
2- Data Entry ( Add , edit , Delete data .........)
3- client / Customer ( he only should see has record and cant change or add or Delete ) i decide to apple GROUP ID NO 5
i want client / Customer can see has record only
How i can make that
i know how i can change owner by use ( change owner ) in table
but i like make every thing work automatically without Data Entry user or Admin do anyhing
with my little information i do some steps but i need help from professional people .
i do like this
1- i create new Group in my App name ( client ) without add any user
2- Manual change Group ID to 5 on membership_groups
3- give Client on Table permissions for this group to view only owner and not allow to edit or delete
4- was create table for client ( client table ) have information for client i add for him basic information and add User name , password ...
5- once i add new client on ( client table ) will add new information to membership_users ( user name , password , group , approve and ID )
i make this Query after insert function in hooks
Code: Select all
function cust_before_update(&$data, $memberInfo, &$args) {
$CustomerID = $data["selectedID"];
$memberID = $data['UserName'];
$password = $data['Password'];
$email = $data['Email'];
$Name = $data['MoklNm'];
$member =sqlValue("select COUNT(*) from membership_users where memberID='{$memberID}'");
if($member == 0) {
sql("INSERT INTO `membership_users` set memberID='{$memberID}', passMD5='" . password_hash($password, PASSWORD_DEFAULT) . "', email='{$email}', signupDate='" . @date('Y-m-d') . "', groupID = 5, isBanned= 0, isApproved= 1 , custom1='{$Name}' , custom3='{$CustomerID}'", $eo);
}
sql("UPDATE membership_userrecords SET memberID ='{$memberID}', groupID= 5 WHERE tableName='cust' AND pkValue='{$data['selectedID']}'", $eo);
return TRUE;
}
if he login he will not see any things ( he can see only has information in client table )
like that everything is ok
now how i can change owner for client
i try many time to add query to change owner for him , to add query in table hooks after_insert but not working
its work only after_update , i already know why ,
Code: Select all
sql("UPDATE membership_userrecords SET memberID ='{$memberID}', groupID= 5 WHERE tableName='files' AND pkValue='{$files_id}'", $eo);
Code: Select all
sql("UPDATE membership_userrecords SET memberID ='{$memberID}', groupID= 5 WHERE tableName='files' AND pkValue='{$files_id}'", $eo);
i make some change on xcxcxcx_dml.php file ----- Where xcxcxcx is table name
Code: Select all
// mm: save ownership data
$memberID = $data['Name'];
$member =sqlValue("select memberID from membership_users where custom3='{$memberID}'");
set_record_owner('xcxcxcx', $recID, $member);