Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groups: subtypes of group and user are returned in elgg_get_entitites with empty subtype (Trac #1987) #1987

Closed
elgg-gitbot opened this issue Feb 16, 2013 · 11 comments

Comments

@elgg-gitbot
Copy link

Original ticket http://trac.elgg.org/ticket/1987 on 40204406-01-22 by lowfill, assigned to unknown.

Elgg version: 1.7

Suppose you want to create a group subtype, let say 'projects' you makes something like:
$project = new ElggGroup()
$project->subtype='project';
$project-save();

Now you have groups and projects now try to get a list of projects:

$projects = elgg_get_entitites(array("type"=>"group","subtype"=>'project'));

Here everything ok, now try to get the list of groups

$groups = elgg_get_entitites(array("type"=>"group"));

Now groups have a list of groups AND projects. It is wrong!

It happens because when subtype is blank the SQL generated only checks against the type field so any subtype of users and groups are returned too.

@elgg-gitbot
Copy link
Author

brettp wrote on 40204488-09-01

Try to use:

$group = elgg_get_entities(array(
    'type' => 'group',
    'subtype' => ELGG_ENTITIES_NO_VALUE
));

If that doesn't work, please reopen this ticket.

This constant needs to be documented.

@elgg-gitbot
Copy link
Author

lowfill wrote on 40204546-09-11

It works!

The problem now is that it is not the default behavior in the groups plugin. When I show my groups it shows my groups AND my projects.

I'll attach a patch latter.

@elgg-gitbot
Copy link
Author

Attachment added by lowfill on 40204729-05-19: groups_empty_subtype.patch

@elgg-gitbot
Copy link
Author

Attachment added by lowfill on 40204729-12-02: groups_empty_subtype-core.patch

@elgg-gitbot
Copy link
Author

lowfill wrote on 40204731-07-27

Attached patch to groups module and engine/lib/relationships to fix this problem.

@elgg-gitbot
Copy link
Author

cash wrote on 40205447-12-03

The group patch appears to have been done off of the trunk (1.8) rather than the 1.7 branch. I can figure out what it is doing but we need decide what we want the default to be.

The options are

  1. groups plugin shows all groups
  2. group plugin shows only groups without subtype

Either way some group of people will have to override some group functionality (unless this is made as a parameter). Some people use subtypes to extend the group plugin but expect them to be listed as groups. Others subtype it and want to separate the subtype from the normal groups.

To override this only requires overriding the group page handler for a few pages if this patch does cover everything.

@elgg-gitbot
Copy link
Author

brettp wrote on 40205461-01-26

What is listed by default was discussed for the context of search in #1499. For consistency, I'd argue the bundled plugins should all function the same way when listing users and groups. With search as precedence, this means to list all regardless of subtype.

@elgg-gitbot
Copy link
Author

cash wrote on 40205473-05-26

I agree. Elgg has worked this way for a while. As long as all the pages go through the page handler, this should be easy to change with a plugin.

Diego, you also submitted a patch on the relationships lib. This should probably be its own ticket (though I haven't taken the time to understand what it is doing).

@elgg-gitbot
Copy link
Author

lowfill wrote on 40205753-11-04

The relationships patch comes with the code for fix the method get_entities_from_relationship that is not using the ELGG_ENTITIES_NO_VALUE parameter. I will open a separate ticket for this.

Talking about the groups plugin I think that both behavior should be available through plugin's configuration. It would give to users the freedom to choose what behavior is better for their context without need to change any core code.

@elgg-gitbot
Copy link
Author

cash wrote on 40212997-09-24

Diego, please don't forgot to open a ticket for the relationship patch and explain what is not working so we can test for it.

@elgg-gitbot
Copy link
Author

cash wrote on 40230154-12-07

I'm closing this one. Diego, don't forget to open a ticket for the relationship patch as I've said before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant