Hello,
I have a question about the ownership of records by user or group.
The records added with the AppGini-database-app are all linked to a user or group in a table in the DB.
But what if I import records with Excel into the DB, are these records auto-linked to an user/group or must I set the memberrights somewhere?
gr. Mustafa.
Set record owner of external records
Re: Set record owner of external records
Hi Mustafa,
if you insert records using your own code, for example by using sql or importing via an external SQL-tool, you will have to set the owner by yourself.
The good thing is: There is a useful built-in AppGini-function for that: set_record_owner
For example:
Hope this helps!
Regards,
Jan
if you insert records using your own code, for example by using sql or importing via an external SQL-tool, you will have to set the owner by yourself.
The good thing is: There is a useful built-in AppGini-function for that: set_record_owner
Code: Select all
set_record_owner($tablename, $primary_key, $owner_memberID) -- Set/update the owner of given record
Code: Select all
// TODO: create your record in MyTable and get the new record's id
$id = ...; // the primary key of your new record
// set owner
$user = getLoggedMemberID();
set_record_owner("MyTable", $id, $user);
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Set record owner of external records
Hello Jan, thanks for the reply.
I have 2 questions:
1. Is there any way that I can "Set Owner" multiple records at ones?
2. Is the "$owner_memberID" linked to the group, so that the whole group of the user can also access the updated records?
And 1 sub-question (edited):
And haven't tested it yet, but what if a records doesn't have a owner, so the record doesn't exist in the membership-table.
How does the application react to this, does it hide the records?
I have 2 questions:
1. Is there any way that I can "Set Owner" multiple records at ones?
2. Is the "$owner_memberID" linked to the group, so that the whole group of the user can also access the updated records?
And 1 sub-question (edited):
And haven't tested it yet, but what if a records doesn't have a owner, so the record doesn't exist in the membership-table.
How does the application react to this, does it hide the records?
Re: Set record owner of external records
Hello!
Question 1:
Yes, there are several ways.
When you are using the built-in set_record_owner()-function, you will have to pass a memberID. Then AppGini will automatically detect the member's group and assign the record to that user and his/her group. It depends on the configured permissions on that table who can see, edit or delete that record. You can control all permissions from the administration area of your AppGini app.
Hope this helps!
Regards,
Jan
Question 1:
Yes, there are several ways.
- Your can load all records using the built-in sql()-function and for each item call the set_record_owner()-function. This method is less efficient than the next one, but easy to implement.
- Have a look at membership_userrecords-table. This table is not complex. You can build an INSERT statement for all items of your table which do not yet exist in membership_userrecords-table and insert them using pure SQL. This is a bit more efficient but more complex. See columns "tableName" and "pkValue" in membership_userrecords-table.
When you are using the built-in set_record_owner()-function, you will have to pass a memberID. Then AppGini will automatically detect the member's group and assign the record to that user and his/her group. It depends on the configured permissions on that table who can see, edit or delete that record. You can control all permissions from the administration area of your AppGini app.
Hope this helps!
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools