DataQube VIP
Total posts: 16
11 Feb 2017 14:34

Hi guys

I have a question for Cobalt 8. Is it possible that articles of a disabled (blocked) joomla user to not participating to any cobalt results (search, filter results, lists)

I can hide the items on lists by adding on list template


<?php foreach ($this->items AS $item):?> <?php // code addition begin: if record owner is disabled do not display record ?> <?php if(JFactory::getUser($item->user_id)->block == '1') continue; ?> <?php // code addition end ?>

but the results count, filters etc are not right.

Last Modified: 14 Feb 2017


Guest
11 Feb 2017 16:55

I was in a hurry, so I did some work myself... I manage to find a solution for List Results by modifying components/com_cobalt/models/records.php

from('#__js_res_record AS r'); // code addition begin - do not select records if user is disabled in joomla $query->where('r.user_id NOT IN (SELECT id FROM #__users WHERE block=1)') ; // code addition end ?> This is doing what I want but still the filters are populated with records from the disabled user I will continue work on that now.


DataQube VIP
Total posts: 16
11 Feb 2017 20:29

Sorry for the previous post as guest

The whole solution:

For the list view I had to modify file components/com_cobalt/models/records.php

<?php
// 1. ListQuery 
// @ components/com_cobalt/models/records.php
// @ function getListQuery
//
// Line 176
$query->from('#__js_res_record AS r');

// code addition begin ===============================================
// do not select records if user is disabled
$query->where('r.user_id NOT IN (SELECT id FROM #__users WHERE block=1)') ;
// code addition end =====================================================
?>

For the filters I had to modify file /components/com_cobalt/library/php/fields/cobaltselectable.php

<?php
// 2. Filters 
// @ /components/com_cobalt/library/php/fields/cobaltselectable.php
// @ Function onRenderFilter
//
// Line 120
$query->from('#__js_res_record_values');

// code addition begin ==================================================
// do not select filter records if user is disabled
$query->where('user_id NOT IN (SELECT id FROM #__users WHERE block=1)') ;
// code addition end ====================================================
?>

The topic can be closed.

Vangelis


pepperstreet VIP
Total posts: 3,837
12 Feb 2017 17:37

Hello Vangelis, this is an interesting topic. I was following, but actually couldn't help you out.
Many thanks for your contributions and insights! Very much apprecuated.

One quick idea: if you really need to change things in the "model", you might consider an MVC override. Just thinking loud…


Topic turned into IDEA

I think this behavior and impact on results is worth to discuss for a build-in feature.
Most likely blocked users are disabled for an important reason.
So it makes total sense to ommit their records and influence in all locations.
IMHO, it is comparable to unpublished content.

@Sergey
Maybe this could be a permanent functionality,
or maybe even an optional setting and toggle.


DataQube VIP
Total posts: 16
14 Feb 2017 15:30

pepperstreet Hello Vangelis, this is an interesting topic. I was following, but actually couldn't help you out.

Many thanks for your contributions and insights! Very much apprecuated.

One quick idea: if you really need to change things in the "model", you might consider an MVC override. Just thinking loud…


Topic turned into IDEA

I think this behavior and impact on results is worth to discuss for a build-in feature.

Most likely blocked users are disabled for an important reason.

So it makes total sense to ommit their records and influence in all locations.

IMHO, it is comparable to unpublished content.

@Sergey

Maybe this could be a permanent functionality,

or maybe even an optional setting and toggle.

pepperstreet Hello Vangelis, this is an interesting topic. I was following, but actually couldn't help you out.

Many thanks for your contributions and insights! Very much apprecuated.

One quick idea: if you really need to change things in the "model", you might consider an MVC override. Just thinking loud…


Topic turned into IDEA

I think this behavior and impact on results is worth to discuss for a build-in feature.

Most likely blocked users are disabled for an important reason.

So it makes total sense to ommit their records and influence in all locations.

IMHO, it is comparable to unpublished content.

@Sergey

Maybe this could be a permanent functionality,

or maybe even an optional setting and toggle.

Powered by Cobalt