diff --git a/og.module b/og.module index 1c7750b6..f765a1d3 100644 --- a/og.module +++ b/og.module @@ -3880,9 +3880,22 @@ function og_autoload_info() { 'OgBehaviorHandler' => 'plugins/entityreference/behavior/OgBehaviorHandler.class.php', 'OgWidgetHandler' => 'plugins/entityreference/behavior/OgWidgetHandler.class.php', 'OgSelectionHandler' => 'plugins/entityreference/selection/OgSelectionHandler.class.php', + 'OgNodeGroupLayoutAccess' => 'plugins/access/OgNodeGroupLayoutAccess.class.php', + 'OgMemberLayoutAccess' => 'plugins/access/OgMemberLayoutAccess.class.php', + 'OgPermLayoutAccess' => 'plugins/access/OgPermLayoutAccess.class.php', + 'OgNodeGroupContentLayoutAccess' => 'plugins/access/OgNodeGroupContentLayoutAccess.class.php', 'og_context' => 'includes/og_context.inc', 'og_context_required' => 'includes/og_context.inc', 'og_context_optional' => 'includes/og_context.inc', 'OgTestBase' => 'tests/og.test', ); } + +/** + * Implements hook_layout_api(). + */ +function og_layout_api() { + return array( + 'file' => 'includes/og.layout.inc', + ); +} diff --git a/og.og.inc b/og.og.inc index e84d2f2d..06b65d63 100644 --- a/og.og.inc +++ b/og.og.inc @@ -13,50 +13,6 @@ function og_og_info() { $info = array( - 'access' => array( - 'og_is_node_group_content' => array( - 'title' => t("OG: Node is an OG group content"), - 'description' => t('Control access by whether or not a node is of type "Group content".'), - 'callback' => 'og_is_node_group_content_check', - 'summary' => 'og_is_node_group_content_summary', - 'required context' => new og_context_required(t('Node'), 'node'), - 'file' => 'plugins/access/og_is_node_group_content.inc', - ), - 'og_is_node_group' => array( - 'title' => t("OG: Node is an OG group"), - 'description' => t('Control access by whether or not a node is of type "Group".'), - 'callback' => 'og_is_node_group_check', - 'summary' => 'og_is_node_group_summary', - 'required context' => new og_context_required(t('Node'), 'node'), - 'file' => 'plugins/access/og_is_node_group.inc', - ), - 'og_member' => array( - 'title' => t("OG: user membership in group"), - 'description' => t('Control access by group membership.'), - 'callback' => 'og_member_access_check', - 'default' => array('state' => OG_STATE_ACTIVE), - 'settings form' => 'og_member_access_settings', - 'summary' => 'og_member_access_summary', - 'required context' => array( - new og_context_required(t('User'), 'user'), - new og_context_required(t('Node'), 'node'), - ), - 'file' => 'plugins/access/og_member.inc', - ), - 'og_perm' => array( - 'title' => t("OG: user permission in group"), - 'description' => t('Control access by group permission string.'), - 'callback' => 'og_perm_access_check', - 'default' => array('perm' => ''), - 'settings form' => 'og_perm_access_settings', - 'summary' => 'og_perm_access_summary', - 'required context' => array( - new og_context_required(t('User'), 'user'), - new og_context_required(t('Node'), 'node'), - ), - 'file' => 'plugins/access/og_perm.inc', - ), - ), 'relationships' => array( 'og_membership_from_group_and_user' => array( 'title' => t('OG membership from a group node and user'), diff --git a/plugins/access/og_is_node_group.inc b/plugins/access/og_is_node_group.inc deleted file mode 100644 index 05e4e5e0..00000000 --- a/plugins/access/og_is_node_group.inc +++ /dev/null @@ -1,27 +0,0 @@ -data) || empty($context->data->nid)) { - return FALSE; - } - - return og_is_group('node', $context->data); -} - -/** - * Provide a summary description based upon the specified context - */ -function og_is_node_group_summary($conf, $context) { - return t('@identifier is an OG group', array('@identifier' => $context->identifier)); -} diff --git a/plugins/access/og_is_node_group_content.inc b/plugins/access/og_is_node_group_content.inc deleted file mode 100644 index b25e625e..00000000 --- a/plugins/access/og_is_node_group_content.inc +++ /dev/null @@ -1,27 +0,0 @@ -data) || empty($context->data->type)) { - return FALSE; - } - - return og_is_group_content_type('node', $context->data->type); -} - -/** - * Provide a summary description based upon the specified context - */ -function og_is_node_group_content_summary($conf, $context) { - return t('@identifier is an OG group content', array('@identifier' => $context->identifier)); -} diff --git a/plugins/access/og_member.inc b/plugins/access/og_member.inc deleted file mode 100644 index 052209cb..00000000 --- a/plugins/access/og_member.inc +++ /dev/null @@ -1,60 +0,0 @@ - 'select', - '#options' => og_group_content_states(), - '#title' => t('State in group'), - '#multiple' => TRUE, - '#default_value' => $conf['state'], - '#description' => t('Only users with the specified state in group will be able to access this.'), - '#required' => TRUE, - ); - - return $form; -} - -/** - * Check for access. - */ -function og_member_access_check($conf, $context) { - // As far as I know there should always be a context at this point, but this - // is safe. - list($user_context, $node_context) = $context; - if (empty($user_context) || empty($user_context->data)) { - return; - } - - if (empty($node_context) || empty($node_context->data)) { - return; - } - - $account = clone $user_context->data; - $node = $node_context->data; - - return og_is_member('node', $node->nid, 'user', $account, $conf['state']); -} - -/** - * Provide a summary description based upon the checked roles. - */ -function og_member_access_summary($conf, $context) { - list($user_context, $node_context) = $context; - - $states = og_group_content_states(); - $state = array(); - foreach ($conf['state'] as $value) { - $state[] = $states[$value]; - } - - return t('@identifier has "@state in @group group"', array('@identifier' => $user_context->identifier, '@state' => implode(',', $state), '@group' => $node_context->identifier)); -} - diff --git a/plugins/access/og_perm.inc b/plugins/access/og_perm.inc deleted file mode 100644 index bfc90b81..00000000 --- a/plugins/access/og_perm.inc +++ /dev/null @@ -1,63 +0,0 @@ - $value) { - // By keeping them keyed by module we can use optgroups with the - // 'select' type. - $perms[$value['module']][$perm] = $value['title']; - } - - $form['settings']['perm'] = array( - '#type' => 'select', - '#options' => $perms, - '#title' => t('Group permission'), - '#default_value' => $conf['perm'], - '#description' => t('Only users with the selected permission flag, in the specified group, will be able to access this.'), - '#required' => TRUE, - ); - - return $form; -} - -/** - * Check for access. - */ -function og_perm_access_check($conf, $context) { - // As far as I know there should always be a context at this point, but this - // is safe. - list($user_context, $node_context) = $context; - if (empty($user_context) || empty($user_context->data)) { - return; - } - - if (empty($node_context) || empty($node_context->data)) { - return; - } - - $account = clone $user_context->data; - $node = $node_context->data; - - return og_user_access('node', $node->nid, $conf['perm'], $account); -} - -/** - * Provide a summary description based upon the checked permissions. - */ -function og_perm_access_summary($conf, $context) { - list($user_context, $node_context) = $context; - - $permissions = og_get_permissions(); - return t('@identifier has "@perm in @group group"', array('@identifier' => $user_context->identifier, '@perm' => $permissions[$conf['perm']]['title'], '@group' => $node_context->identifier)); -} -