Hiding the Detail View From A Group

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
gmusgrave
Posts: 25
Joined: 2013-08-15 17:27
Location: Mexico

Hiding the Detail View From A Group

Post by gmusgrave » 2015-02-13 17:13

I have an application where I've set permissions for the anonymous user to view a table, but not to be able to edit or insert.

When this user visits the Table View page they get a target link when they mouse over the contents of a column. When they click on this link, they see a Detail View. This Detail View is informational only, and nothing is editable (it respects the permissions).

What I would prefer is that there is no link and no Detail View available. The non-editable Detail View is simply a distraction.

I can't simply turn off Detail View for the table because the admin needs to have a Detail View to edit the table.

1. Does anyone know of a way of defeating the entire Detail View mechanism including the target link on each column for a particular group?

2. If not, is there an elegant way of preventing this link from displaying a Table View when clicked?


I've tried using the tableview_dv() function in the hook file like so:

Code: Select all

		// No Detail View for non-admins
		if ($memberInfo['group'] == 'anonymous') 
			{
			$html = ""; // Clear the Detail View HTML
			header("Refresh:0"); // Reload the script
			} 
This works after a fashion, but is not elegant. It has an annoying side effect. When the user clicks on the target link, the column background changes to the editing highlight colour, and the column loses it's ability to wrap (normal behaviour with Detail View). Then a short time later, the page refreshes and all is well again. This is better than displaying a useless Detail View, but is somewhat glitchy.

I can modify this behaviour by setting the Detail View as a separate page. Now, I don't get the row highlighting and unwrapping, but the table view momentarily disappears, then the page reloads and re-displays it. Still not exactly elegant.

Is there a better way to do this?

Thanks,
Garry

gmusgrave
Posts: 25
Joined: 2013-08-15 17:27
Location: Mexico

Re: Hiding the Detail View From A Group

Post by gmusgrave » 2015-02-16 18:09

SOLVED!

Thanks to the amazing flexibility of AppGini, after a bit of digging, I found that it's actually quite simple to do this.

In the AppGini application you can decide if a field is clickable to Detail View or not by selecting "Select the record in the detail view (default behavior)" or "No action (text only without link".

Unfortunately, if you choose the latter, there are no more clickable links to Detail View – ever. This disallows an admin from selecting an item to edit.

Sooo....

1. Set set all (or some) fields to "Select the record..." to make sure we allow Detail View links for the admin, and generate the PHP code.

2. Make a copy of the TABLENAME_templateTV.html template file in the templates folder, save it under a new name (such as TABLENAME_templateTV_nonadmins.html), and put it in the hooks folder.

3. In this new template file, delete the <%%SELECT%%> ... <%%ENDSELECT%%> tags from each field.

4. In the TABLENAME_view.php hooks file, modify the TABLENAME_init() function to include:

Code: Select all

if ($memberInfo['group'] == 'anonymous') 
			{
			$options->Template = 'hooks/TABLENAME_templateTV_nonadmin.html';
			}
Now when a non-admin user is viewing the Table View, there will be no clickable links. But when an admin views the Table View, it will work as expected with Detail View links for editing.

SkayyHH
Veteran Member
Posts: 481
Joined: 2015-04-27 21:18

Re: Hiding the Detail View From A Group

Post by SkayyHH » 2015-05-12 19:55

Hello, this i great :-)

Any idea how to do the same not with the group but with all record where the user is not the owner of the records?

I like to have detail view of owned records but no detail view of other records.

Thanks much, Kai

Post Reply