Editor - Permissions to create, edit or delete records
Editor - Permissions to create, edit or delete records
peterbrowne
Posts: 314Questions: 54Answers: 0
Is there a way to set user permissions to create, edit or delete records and just have a read only permission?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @peterbrowne ,
This page of the manual should help, it discusses that.
Cheers,
Colin
I need to set permissions at the highest level for all datatables instances, not for individual fields.
So a person with read only permission will not see any Editor buttons for any tables.
A person with edit function will only see the Edit button.
An admin or super user will have access to all editor buttons for all tables.
I would have thought this would be a fundamental need...
So on the $_SESSION global there may be:
$_SESSION['cm_user'] = Array ( [cm_user] => Array ( [user] => '123456' [permission] => 'edit' ) [LAST_ACTIVITY] => 1573091380 )
You are right - it is a fairly fundamental need in a CRUD system. However, Editor makes no assumptions about the authentication / session framework you are using, so a little bit of code is required.
That information needs to be given to the client-side, since it is the client-side that is rendering the buttons.
So you could do something like:
Typically I have a little bit of PHP generating Javascript to get that kind of information from the PHP session into Javascript.
Allan
Thanks Allan.
How should I modify the DataTables initialisation to get this to work? I have tried removing the buttons part of the code, but it breaks the DataTable.
Also using the code below prduces an error:
DataTables warning: table id=year_table - Cannot reinitialise DataTable.
Also tried:
But datatable does not have any buttons
Apologies - the function should have been
button().add()
(not the pluralbuttons()
) and I'd forgotten about the index for the button as well:So it should be:
Here is a little example: http://live.datatables.net/garofaba/1/edit (using the print button).
Allan
And here it is with Editor's buttons: http://live.datatables.net/lucidiba/2/edit
Brilliant! Works great.
Thanks