Page 1 of 1

edit button only for edit permission

Posted: 2021-05-17 01:03
by baudwalker
I have added a button to the table view

Code: Select all

jQuery(function () {
  var tv = new AppGiniTableView();
  // additional buttons for table view
  // add "open" button
  var tablename = AppGini.currentTableName();
  var url_open = tablename + "_view.php?SelectedID=%ID%";
  tv.addLink(url_open, "pencil", "Edit", Variation.primary);
  tv.setWidth(0, 20);
});
This works fin, but it is available to all, even those who do not have edit permissions. How can this be rectified?

Re: edit button only for edit permission

Posted: 2021-05-17 11:57
by onoehring
Hi,

I would probably check on PHP basis IF the current user has edit permissions. If he has, add the code. How? Maybe like so:
footer-extras.php add the code to check what page (table) user tries to open , then check if user has permissions -> if yes -> output the js code (or maybe easier to handle) include a file that contains this code.

Olaf