edit button only for edit permission

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

edit button only for edit permission

Post by baudwalker » 2021-05-17 01:03

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?

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: edit button only for edit permission

Post by onoehring » 2021-05-17 11:57

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

Post Reply