danielbidala VIP
Total posts: 153
04 Dec 2014 20:24

First of all thanks for the sequential updates.

I'm in a new project and have a question. Is it possible to manage who can see the record (per record). For example there is Super User how can add new record and can set one or more Registerd user who can see this record in category view or the record itself in record view. Registred users can't edit records.

Thanks in advance

Last Modified: 10 Dec 2014


pepperstreet VIP
Total posts: 3,837
05 Dec 2014 00:12

Like J! articles, records can only have 1 owner/author. So, changing the owner does not help in your case. Although it would work for single user/record relations.

Joomla core ACL allows to have multiple usergroups, therefor it would allow to have multiple users. That route would give multiple users access... but it requires to add your users to a certain usergroup first, and then to an ACL. Only that ACL can be selected in Cobalt's parameters for access restriction. (Not really a suitable workflow, I guess it would end-up in many many groups and ACLs)


BTW, here is a related topic/discussion ...


danielbidala VIP
Total posts: 153
05 Dec 2014 14:50

Sergey? Do you have any suggestion? I tought I place an sql field where Super User can select one or more user. Then in category list template I check this field and logged in user meet or not. If not he won't see the record.

But the second step cause me headaches.


Sergey
Total posts: 13,748
08 Dec 2014 08:32

To restrict per user, you select that гук as an author of that article and set article access special.

To restrict for number of users, create new user group, create new access level and use that access level when you create article.


danielbidala VIP
Total posts: 153
08 Dec 2014 11:52

Thanks Sergey! Unfortunetly this doesn't work for me. If I create user groups and ACL for every combination of user it will ends up a lot of groups and ACL.

I rather use an sql field (field_XY) where admin can select one or more user when crete article and if statement somewhere in records list php.

For example: if logged in user = field_XY or logged in user is Super User

<?php foreach ($this->items AS $item):?>

and so on...

My only problem I don't know how and where to build the if statement in records list php :-(


Sergey
Total posts: 13,748
09 Dec 2014 02:59

Then you can do this.

  1. Create Listautocomplete field with SQL source from users table.
  2. In custom article full view template, on top, check this field value. If there is something and current user ID is not in the list, then just redirect user back to list of articles. Somethign like this.
$ids = $item->fields_by_id[12]->value;
if(is_array($ids) && count($ids) > 0) 
{
    if(!in_array($this->user->get('id'), $ids)) {
        JFactory::getApplication()->redirect(Url::records($this->section, $this->category));
    }
}

pepperstreet VIP
Total posts: 3,837
09 Dec 2014 05:21

Sergey Create Listautocomplete field with SQL source from users table.

Or Multi-Select field with optional parameter for "Chosen" input style.


danielbidala VIP
Total posts: 153
09 Dec 2014 07:19

Ok this sounds good but what to do if I don't want unassigned users to see record in records list (category view). Is there a way to modify default list template to do this. Thanks in advance.


Sergey
Total posts: 13,748
10 Dec 2014 02:00

pepperstreet

Sergey Create Listautocomplete field with SQL source from users table.

Or Multi-Select field with optional parameter for "Chosen" input style.

Yes, but only if theer are not so many users. Listautocomplete will load users with ajax and mitiple select will preload it. So page load may become an issue.

danielbidala Ok this sounds good but what to do if I don't want unassigned users to see record in records list (category view). Is there a way to modify default list template to do this. Thanks in advance.

Unfortunately no. There is no such a way whithout haking Cobalt core.

Powered by Cobalt