@@ 41-57 (lines=17) @@ | ||
38 | $autogroups = split(',', $autogroups); |
|
39 | ||
40 | //for each group id |
|
41 | foreach($autogroups as $group){ |
|
42 | $ia = elgg_set_ignore_access(true); |
|
43 | $groupEnt = get_entity($group); |
|
44 | elgg_set_ignore_access($ia); |
|
45 | //if group exists, submit to group |
|
46 | if( $groupEnt ){ |
|
47 | //join group succeed? |
|
48 | if( $groupEnt->join($object) ){ |
|
49 | add_entity_relationship($object->guid, 'cp_subscribed_to_email', $groupEnt->guid); |
|
50 | add_entity_relationship($object->guid, 'cp_subscribed_to_site_mail', $groupEnt->guid); |
|
51 | ||
52 | // Remove any invite or join request flags |
|
53 | elgg_delete_metadata(array('guid' => $object->guid, 'metadata_name' => 'group_invite', 'metadata_value' => $groupEnt->guid, 'limit' => false)); |
|
54 | elgg_delete_metadata(array('guid' => $object->guid, 'metadata_name' => 'group_join_request', 'metadata_value' => $groupEnt->guid, 'limit' => false)); |
|
55 | } |
|
56 | } |
|
57 | } |
|
58 | ||
59 | //retrieve group ids from plugin |
|
60 | $organizationgroups = elgg_get_plugin_setting('organizationgroups', 'gc_autosubscribegroup'); |
|
@@ 130-147 (lines=18) @@ | ||
127 | $groups = split(',', $groups); |
|
128 | ||
129 | //for each group id |
|
130 | foreach($groups as $groupId){ |
|
131 | $ia = elgg_set_ignore_access(true); |
|
132 | $groupEnt = get_entity($groupId); |
|
133 | elgg_set_ignore_access($ia); |
|
134 | $userEnt = get_user($object->owner_guid); |
|
135 | //if group exists, submit to group |
|
136 | if( $groupEnt ){ |
|
137 | //join group succeed? |
|
138 | if( $groupEnt->join($userEnt) ){ |
|
139 | add_entity_relationship($userEnt->guid, 'cp_subscribed_to_email', $groupEnt->guid); |
|
140 | add_entity_relationship($userEnt->guid, 'cp_subscribed_to_site_mail', $groupEnt->guid); |
|
141 | ||
142 | // Remove any invite or join request flags |
|
143 | elgg_delete_metadata(array('guid' => $userEnt->guid, 'metadata_name' => 'group_invite', 'metadata_value' => $groupEnt->guid, 'limit' => false)); |
|
144 | elgg_delete_metadata(array('guid' => $userEnt->guid, 'metadata_name' => 'group_join_request', 'metadata_value' => $groupEnt->guid, 'limit' => false)); |
|
145 | } |
|
146 | } |
|
147 | } |
|
148 | } |
|
149 | } |
|
150 |