Welcome, Guest
Username: Password: Remember me

TOPIC: User permissions for different tables

User permissions for different tables 25 Sep 2012 18:10 #3988

Hello,

I'm building a very simple component. It has one table ("Company") that lists company names, and one table ("User_Company") that associates those company names to users. On the front end the user should be able to add a record to the Company table, and also add records to the "User_Company" table so they can associate their user id with one or more companies.

If I set user permissions to "Create/Edit/Delete" the user can see all of the records in the User_Company table, not just their own. If I only allow "View/Edit/Delete Own" the user can only see their records in the User_Company table -- perfect. But if they access the form to create a new record, they can only see the names of companies in the Company table that they created.

Is there a way around this problem? Basically, I want one layout where the user can only see their records, and a form where the drop-down field allows them to select from all records, not just their own.
Last Edit: 03 Oct 2012 13:28 by admin.
The administrator has disabled public write access.

Re: User permissions for different tables 25 Sep 2012 18:15 #3990

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Combine with publish wizard.

Try to instance the publish wizard, and let the publish state to false for each item.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: User permissions for different tables 25 Sep 2012 18:24 #3991

In the table "Company" I have used the publish wizard. I changed its default value to "0", but the front end user can still only see records from that table that they have created.
The administrator has disabled public write access.

Re: User permissions for different tables 25 Sep 2012 18:37 #3992

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I read better, and I understand better your problem.

As you can see, the model is protecting the access everywhere, you cannot do any mistake.

To skip this, change the query related to the list filling, in the list model of Companies, function prepareQuery().

The query is called from the view where your combo is.
The best to do that is to play with states vars.
$model->setState('filter.published', null);

Not tested.
If it do not work, try to play around in prepareQuery() + new state vars.
Coding is now a piece of cake
Last Edit: 25 Sep 2012 18:38 by admin.
The administrator has disabled public write access.
Time to create page: 0.087 seconds

Get Started