Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Cannot save group reference field programmatically #137

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class og_context_plugin_access_og_perm extends views_plugin_access {
'#title' => t('Argument position for group ID'),
'#default_value' => $this->options['group_id_arg'],
'#options' => array(NULL => t('None')) + range(0, 9),
'#description' => t('Group ID argument position with arg() function. e.g. if your dynamic path is "node/%/group/%/overview" and you are using the second "%" for group IDs you have to choose "3" like "arg(3)".'),
'#description' => t('The position of the Group ID argument in the view\'s path. The position is 0-based. E.g. if your dynamic path is "node/%/group/%/overview" and you are using the second "%" for group IDs, you have to choose "3".'),
);
}
}
Expand Down Expand Up @@ -98,6 +98,16 @@ class og_context_plugin_access_og_perm extends views_plugin_access {
* Determine the access callback and arguments.
*/
function get_access_callback() {
return array('_og_context_views_page_access', array($this->options['group_type'], $this->options['perm'], $this->options['group_id_arg']));
$current_display = $this->view->current_display;
if ($this->view->display[$current_display]->handler->has_path()) {
// The arg number needs to be int. That way it will be replaced with the
// group id in the path before _og_context_views_page_access is called.
$group_id_arg = (int)$this->options['group_id_arg'];
}
else {
$group_id_arg = FALSE;
}

return array('_og_context_views_page_access', array($this->options['group_type'], $this->options['perm'], $group_id_arg));
}
}
9 changes: 4 additions & 5 deletions og_context/og_context.module
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,14 @@ function _group_context_handler_entity($entity_type = 'node', $entity = NULL, $p
* The group type.
* @param $perm
* The group permission to search for.
* @param $group_id_arg
* Optional; The position in arg() where the group ID can be found.
* @param $gid
* The group id from the path.
*
* @return
* TRUE if user is allowed access to the page.
*/
function _og_context_views_page_access($group_type, $perm, $group_id_arg = FALSE) {
if ($group_id_arg !== '') {
$gid = arg($group_id_arg);
function _og_context_views_page_access($group_type, $perm, $gid) {
if ($gid) {
if (is_numeric($gid)) {
return og_user_access($group_type, $gid, $perm);
}
Expand Down
4 changes: 0 additions & 4 deletions plugins/entityreference/behavior/OgBehaviorHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ public function delete($entity_type, $entity, $field, $instance, $langcode, &$it
* Create, update or delete OG membership based on field values.
*/
public function OgMembershipCrud($entity_type, $entity, $field, $instance, $langcode, &$items) {
if (!user_access('administer group') && !field_access('edit', $field, $entity_type, $entity)) {
// User has no access to field.
return;
}
if (!$diff = $this->groupAudiencegetDiff($entity_type, $entity, $field, $instance, $langcode, $items)) {
return;
}
Expand Down