Drupal 7 Organic Groups: Cannot Specify Membership Type - drupal-7

I have an og course group type (not group content). I need to add members to the created groups. I have two groups: students and instructors.
I have added two OG memberships types ("student membership" and "instructor membership") each with a different set of fields that the user should submit when subscribing to a group:
1- Student
2- Instructor
The problem is that the fields that appear are only those in the "default" membership type and neither the members (students or instructors) nor the admin can select the membership type.
I am also struggling to understand where I should specify the membership type for each group type.
Can anyone provide a step by step guide for this?
P.N: I also keep seeing this message Notice: Undefined index: membership_type in og_entity_property_info() (line 236 of /home/devkat/public_html/albinacourses/sites/all/modules/og/og.module).
Thanks a million!

Related

Number of fields

I am new in salesforce and I have a question. I am creating a new reporty type using opportunites and when I was in field layout properties I noticed there were total 40 fields for opporutiy object. I didnt had another object relation with opportunity just simple opportunity. But when I went to opportunity in in object manager there were only 29 items listed in fields and realtionship. Why are there 11 more fields in opportunity in reprot type then in fields and realtuionship
I was expeting the same number of fields in object manager and in report type but report type had more fields even when no object was linked with it
There's a number of fields that exist in the table but aren't visible in setup because you can't modify them, can't change user's right to see/edit them. It's bit like https://help.salesforce.com/s/articleView?id=sf.dev_objectfields.htm&type=5 but it doesn't mention CreatedDate, LastmodifiedDate, SystemModStamp... and on Opportunity there are more.
https://developer.salesforce.com/docs/atlas.en-us.238.0.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm may be a good start but if you truly want everything - run a "describe" operation in Apex or maybe REST API (https://workbench.developerforce.com/ -> utilities -> rest explorer for example)

OWL/Protege: Model inferred class of persons, who are not members of a group

I try to create an ontology in OWL, using Protégé 5.5.0. No I have a little trouble with inferred classes.
I have three classes: Agents and as subclasses Groups and Persons. Persons can be members of Groups. Now I want to create two inferred classes: a) "Members of groups" and b) "Not members of groups" (both as subclasses of Person)
I was successful with a), using the axiom equivalent class: Person and member_of some Group.
I created one individual, which is a person and member of a group and it was inferred to be member of the class "Members of groups".
Now I'm stuck with b). I tried several options for the equivalent class, for example:
Person and member_of max 0 Group
Or: Person and member_of exactly 0 Group
Or: Person and not member_of some Group
I created an individual which is a person but no groupmember. But the reasoner does not agree with me about the fact, that this individual should belong to the inferred class "Not members of groups".
What did I do wrong?
One way to achieve this in OWL, using your Person and not member_of some Group,
is to define a MemberOfGroup class that is defined as you suggested. Then define a NotMemberOfGroup class, that is disjoint with the MemberOfGroup class. If you now define your individual to be of type Person, as well as of type not member_of some Group, then your individual will be classified as belonging to the NotMemberOfGroup class.
The reason why you have to do this, is that OWL uses the open world assumption and hence it can only make inferences about things it knows for sure. I.e. saying that the individual is a Person, while making no statement regarding member_of provides the reasoner with zero explicit info to determine that the individual either belongs or does not to a group.
The other option is to use SHACL/SHEX/SPIN.

Get users "memberOf" AD-groups

I try to get all users "memberOf" all groups begining with "JE_"
I know that I cannot do the following:
memberOf=CN=JE*,OU=JE,OU=Gruppen,DC=subd,DC=dom,DC=net
But all the JE_* are located under a knot called "JE". Is it possible to get all users memberOf the groups located under the knot "JE"?
yes but you need to approach the problem differently. Rather than search against the user object you should search against teh group object with the user's DN.
For example, consider the user
cn=dave,OU=user,DC=subd,DC=dom,DC=net
The user is a member of several JE* groups.
CN=JE_1,OU=JE,OU=Gruppen,DC=subd,DC=dom,DC=net
CN=JE_2,OU=JE,OU=Gruppen,DC=subd,DC=dom,DC=net
CN=JE_3,OU=JE,OU=Gruppen,DC=subd,DC=dom,DC=net
In order to find the JE* groups to which the user belongs search for groups with a base of OU=JE,OU=Gruppen,DC=subd,DC=dom,DC=net and a search filter of
(&(objectclass=group)(member=cn=dave,OU=user,DC=subd,DC=dom,DC=net))
That will return all of the JE* group objects that contain the user in question. Ensure to specify that you only want the group name returned as an attribute otherwise all of the members will be returned too. Not a problem if there are only a handful but it might be a nuisance if there are thousands.

Drupal 7: Using Rules to add user to OG then assign OG role

The idea is to accomplish the following when a new user is added:
Create a new group (OG)
Save it
Add user to saved group (OG)
Assign group role (OG)
I am using Rules with Organic Groups. All is fine apart from assigning the group role. I know you can add general system roles but does anyone know how to assign a group (OG) role programmaticaly so it happens automagically?
Any help much appreciated
I use the following custom php action on a rule, to add user to group and assign OG role.
OG role numbers appear to be in order of OG roles, as viewed through admin/config OG entries.
global $user;
// Load the user we want to add to the group
$account = user_load($user->uid);
// Add the user to the group - hard code group 18 which is my group as cant
// get PID from Ubercart order, to pull gid from nid. User, current user, active,
// etc., all default in 2nd array() param to og_group.
og_group(18);
// Changes the users role in the group (1 = non-member, 2 = member, 3 = administrator member, 4 = Forum Administrator)
og_role_grant(18, $account->uid, 2);
Note, OG role 4 (forum administrator) is a custom OG role I created. Also, 'member' (2) is the default, I believe, but I put this in so I'd remember how to allocate other OG roles if I needed to in future.
I'm not a php guru unfortunately, and I still havent worked out how to pull the pid from the node of the Ubercart product ordered so I can get its gid and hence not hard code the gid of 18.
Hope the above code snipped (og_role_grant mainly) works for you as a rule action custom php code snippet (remember not to include the php tags at top and bottom as rules does this for you).
If you have any thoughts on my problem of getting the gid of the ordered ubercart product, as above, please feel free to share. :)
Best wishes
There is a proposed Organic Group patch that add this functionality to the Organic Group Rules integration.
You can find the patch here: https://drupal.org/node/1327326
It adds Grant and Revoke role actions.
You can use og_role_grant($group_type, $gid, $uid, $rid) to assign a role to a user into an organic group programmatically.
To use this with rules, you can define a custom action using hook_rules_action_info() .

Prepopulating group_audience field in Drupal 7 (Organic Groups)

I'm trying to get the prepopulate module to work with og with little success. From what I understand I can do ?edit[group_audience]=123, and by going through the code it seems the prepopulate plugin does what it is supposed to, and sets the dropdown #value to 123, but for some reason this doesn't work at all.
I've also found some information saying that it is possible to prepopulate the field using ?gids[]=123, has anyone had success with this, or has a real proper solution?
So... the right way to do this for D 7.22 and OG 7.x-2.1 is:
node/add/[content-type-machine-name]?og_group_ref=[group-id]&destination=node/[group-id]
The above answers did not work for my setup.
See how I wasted my Sunday on this here: Drupal Organic Groups Pre-populated Audience Field
Did you try ?edit[group_audience][]=123 ?
Group audience is a multiselect box so it is possible that you need to use this syntax that allow to set multiple values.
?edit[group_audience][]=123&edit[group_audience][]=42&edit[group_audience][]=1
Don't need the prepopulate module:
?gids_group[]=123
Found this in the Organic Groups readme:
You may craft your own URLs which produce useful behavior.
For example,
node/add/group-content?gids_node[]=4
will add a select the group with node ID 4, in the node form.
The prefixed entity can change to indicate other entity
types allowing crafting the URL and you can have multiple variables,
for example,
node/add/group-content?gids_node[]=4&gids_user[]=3&gids_group[]=5,6,7
The above URL will select the group with node ID 4, and the group with user ID
3, and the groups with the unique group ID 5, 6 and 7.
Note that the actual entity of group ID 5, 6 and 7 can be any entity (e.g.
nodes or users).
By appending ?gids[]= to your node/add URL, you can specify the group audience. By throwing in a comma-delimited list of nids, you can specify multiple audiences.
For Drupal 7, with og 7.x-2.1, you need to have the entity reference prepopulate module installed (and follow the instructions in its readme). Once you do that, then the rest works like magic. Without that module installed/enabled, nothing happens when you try to do what is below. This url achieves the desired result of pre-poulating og_group_ref field with the group with id 1135:
http://[site]/node/add/group-post?og_group_ref=1135

Resources