Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dixon_’s picture

Status: Active » Needs review
FileSize
7.15 KB

And here's a first patch. As mentioned, it's work-in-progress, but I'm marking with "needs review" just go get some feedback on if this has a chance of getting in or not ;-)

amitaibu’s picture

I tried to avoid having multiple relationship to a single vocab, mostly because I have a feeling it's hiding some nasty scenarios.
Can you tell a bit more about your use case?

dixon_’s picture

Yes, there are probably a few nasty scenarios you can run into. Mostly I think it comes down to access permissions and group admins being able to delete/edit shared vocabularies which will effect other groups. However, if we document these side effects properly and make this feature opt-in I think it would be valuable.

Here's our use case in more detail:

We're building a (BIG) site were people can submit classified ads for selling or buying things like cars, motorbikes, mobile phones, household items, professional services etc. etc. etc. Sort of Craig's List or Gumtree, but for the country where I currently live.

So how are we using OG and OG Vocab?
Each classified category is a term in a vocabulary. It allows our visitors to enjoy some nice faceted, "drill down" searching, it looks something like this:

  • Electronics
    • TV
    • Mobile devices
      • Mobile phones
      • Tablets
      • ...
  • Motor vehicles
    • Cars
    • Motorbikes
    • Watercrafts
      • Boats
      • Jet skiis
      • ...
    • ...
  • Property
    • Villas
    • Apartments
    • Bed spacers
    • Commercial properties
      • Office space
      • Industrial property
      • ...
    • ...

As you can imagine the list of categories is always expanding and getting more granular as demand grows and new use cases emerge.

The problem we're facing is that ads under each category require a slightly different set of fields or metadata. And we don't want a separate ad content types for each category. That'd be a pain to maintain.

So, we're making each ad category into a group and using og_vocab to let each group define what additional metadata (vocabularies) that's needed for ads in that group. This lets us have one "Ad" content type with the basics (Title, Price, Description etc) and one og_vocabulary field that holds all additional metadata in a semi-structured way.

Example 1: Cars and Motorbikes will share a Transmission vocabulary (Automatic, Manual, Semi-automatic etc.) but only Cars will have a Body vocabulary (Sedan, SUV, Convertible etc).

Example 2: All property categories will share a Parking vocabulary (Covered, Garage, Street etc.) but only the residential categories will have a Available facilities vocabulary (Gym, Pool, Storage room etc.).

amitaibu’s picture

_dixon, can you ping me on IRC?

charlie charles’s picture

I agree, this would be a very useful feature

charlie charles’s picture

I'm not sure if this would help
in your use case dixon

You could have look at the

https://drupal.org/project/relation

It might be help for what your
trying to achieve

dixon_’s picture

Here's what the admin screen looks like where you can add new or attach existing vocabularies to a group.

paranojik’s picture

Could we limit the permissions on the attached (existing) vocabulary to "read-only". So that group administrators could not edit/add/remove tags on the attached vocabularies?

I also have another use case: I would like to implicitly share vocabularies between groups (e.g. child group automatically get all it's parent groups vocabularies...). Is there place for a more extensible mechanism?

RoySegall’s picture

I think i have better idea: why not clone? We can clone vocab to other groups which the user has access to and then we avoiding any scenarios which can caused when we sharing vocabs.

paranojik’s picture

I'm afraid that's not an option. If you want to have a faceted search on those vocabularies (like dixon_ in #3 is doing) then filtering on the shared vocabulary will not work as expected...

no.exploit’s picture

Issue summary: View changes

its Work find Thanks , but When u upload a image Or u make any type of ajax call or Validation field You losing value of og vocabulaire Can you help in this case ?

mpotter’s picture

I found a couple of bugs with this. When you add share a vocabulary with another group, now you can't view/edit the vocabulary as part of one of the groups. It's random which group will break as it depends on the database return order. Basically, the og_vocab_vocabulary_access() function is calling og_vocab_relation_get() which only returns a single record. If this record doesn't match the group you are in, then you get access denied.

One other problem is when removing a vocabulary from a group. In og_vocab_relation_delete() (which is another fix of the mispelled og_vocab_realtion_delete), if the $removed_vids was empty, the EntityFieldQuery at the end would fail with an error.

Now, I do hate to post big patches, but I also hate dependent patches. My main purpose in visiting this patch was to add support for og_subgroups module so children groups could inherit vocabularies of parent groups. This patch was a *great* start with that. Basically I just needed to add an option to the vocabulary to determine if it auto-adds the vocab to the children or not. The combination of og_subgroups functionality along with this patch (which lets you remove a vocab from a specific child if desired) is really powerful.

So, I present the full patch. It fixes the bugs in the #1 patch and adds the og_subgroups support. If you don't use og_subgroups you won't see any of it (it's not a hard dependency). However, in order to use the og_subgroups support, you must enable the og_vocab_allow_shared_vocabularies variable.

mpotter’s picture

A slight tweak to the patch from #12 to fix an error when creating a new vocabulary.

no.exploit’s picture

after i've applayed the patch "*-12.patch" still i'm getting thie error , og_vocab_relation_get() returns a single record (22) in my case
Notice: Undefined index: 22 in og_vocab_relation_get() (line 843 of /var/www/bypass/docroot/sites/all/modules/contrib/og_vocab/og_vocab.module).
can you help please , the second problem when you try to upload a image with og_vocab in the form you losing those values when this type of ajax is called
Many thanks

LNakamura’s picture

I have a somewhat similar use case for which I opened: #2338083: Unable to see vocabularies associated with other groups after node creation. I say "somewhat similar" in that there are multiple OG vocabularies, but each is assigned to just one Group. However, a user with the appropriate role has membership to all groups and can create a post which uses any term from any of the vocabularies - so it doesn't appear to me that the vocabulary sharing described for this feature request is the same thing that I'm trying to do. Or is it? I can't tell.

I'd appreciate any insight that anyone might have to offer.

Thanks!
Lee

no.exploit’s picture

hefox’s picture

Here's a signicant changed patched.

So, was looking into the fact the o#12 is using variable_set to store per vocab info, which is a nono, and came upon the realization that anyone that the vocab is shared with can completely change the vocab as far as bundles, etc. go. That's really not ideal for many use cases, so clamped down on it -- but realized there needs to be a way to say who owns the vocab and have global settings for the vocabulary, so added a new table that tracks the main vocab and settings.

Another problem is that access to edit the terms etc. was only checked on the first vocab in the table.

The major change this patch introduces is og_vocab_relation_get returns an array of relations instead of a single one. I'm debatable whether that's a good idea due to issues of api change.

hefox’s picture

hefox’s picture

Removing dsm and changing the shared vocab logic so can decide what og vocabs are sharable (and adding a hook to add more/change that logic)

hefox’s picture

Forgot to remove a check for og_subgroups when copy and pasting something.

hefox’s picture

making it mark as shared if is already shared

rol’s picture

Hi all, thanks for that patches although i still have a problem with subgroups...

i've this structure:

maingroup1 - og group, group type

--subgroup1 - og group, subgroup type, og group content

maingroup2 - og group, group type

--subgroup2 - og group, subgroup type, og group content

added same og field to both (sub group type, group type) -- og_group_ref_voc

shared vocbaluary = true, propagate subgroup = true

it seems everything goes well but at subgrouptype on edit form no terms of og_voc appears. ( og vocabulary only shows edit terms link on og grup content ). list of terms is empty on edit form, if i check to node/%nid/admin/taxonomy show correctly attached og vocabulary

am i missing something ? someone have same problem? thank you in advance

mpotter’s picture

Status: Needs review » Needs work

Using the patch in #21 in Open Atrium. Let's bump the test-bot

mpotter’s picture

Status: Needs work » Needs review
hefox’s picture

Assigned: dixon_ » Unassigned
FileSize
27.37 KB

Fixing error saving when shared isn't enabled

Status: Needs review » Needs work

The last submitted patch, 25: 2039009-og_vocab-share-25.patch, failed testing.

The last submitted patch, 25: 2039009-og_vocab-share-25.patch, failed testing.

Status: Needs work » Needs review
Tess Bakker’s picture

Removed the 'break' that causes a PHP Fatal error with PHP7 and fixed a code style issue (one of many to go).

jbylsma’s picture

I've rerolled patch #25 with the diff from #29 against the current HEAD (66b7613). Sorry for the noise, hadn't realized the other had a full patch, too.

Locally, the OgVocabApiTestCase and OgVocabComplexWidgetTestCase tests return the same with and without the patch. The OgVocabMenuAccessTestCase test is not completing for either.

MorinLuc0’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
29.22 KB

I added the views support to allow a view to be built off the joining table.

I have a scenario where I needed to build a view of vocabularies and terms that a user had access to across multiple groups.

But beside that this patch is great. RTBC

MorinLuc0’s picture

MorinLuc0’s picture

It appears I made a copy and paste error when I exported the patch, here is the updated one.