You are here

og_subgroups.workflow_ng.inc in Subgroups for Organic groups 5.4

Same filename and directory in other branches
  1. 5 og_subgroups.workflow_ng.inc

og_subgroups.workflow_ng.inc

This include file is enabled when Workflow-ng module is enabled. It adds some actions that allow manipualtion and interaction on groups and sub-groups.

File

og_subgroups.workflow_ng.inc
View source
<?php

/**
 * @file og_subgroups.workflow_ng.inc
 * 
 * This include file is enabled when Workflow-ng module is enabled. 
 * It adds some actions that allow manipualtion and interaction on groups and sub-groups. 
 */

/**
 * Implementation of hook_action_info().
 */
function og_subgroups_action_info() {
  $info = array();
  $info['og_subgroups_workflow_ng_action_set_parent'] = array(
    '#label' => t('Set subgroups hierarchy'),
    '#arguments' => array(
      'node' => array(
        '#entity' => 'node',
        '#label' => t('Content that will be the parent group'),
      ),
      'node_parent' => array(
        '#entity' => 'node',
        '#label' => t('Content that will be the child group'),
      ),
    ),
    '#description' => t('Set groups hierarchy by setting the parent and the child group.'),
    '#module' => 'OG Subgroups',
  );
  $info['og_subgroups_workflow_ng_action_remove_hierarchy'] = array(
    '#label' => t('Remove group from subgroups hierarchy'),
    '#arguments' => array(
      'node' => array(
        '#entity' => 'node',
        '#label' => t('Content that will be removed from the groups hierarchy'),
      ),
    ),
    '#description' => t('Remove the group from the groups hierarchy.'),
    '#module' => 'OG Subgroups',
  );
  return $info;
}

/**
 * Action: Set groups hierarchy.
 */
function og_subgroups_workflow_ng_action_set_parent($node, $node_parent, $settings) {
  og_subgroups_set_hierarchy('insert', $node, $node_parent->nid, TRUE);
}

/**
 * Action: Remove group from hierarchy.
 */
function og_subgroups_workflow_ng_action_remove_hierarchy($node, $settings) {
  og_subgroups_remove_hierarchy($node);
}

/**
 * Implementation of hook_condition_info().
 */
function og_subgroups_condition_info() {
  $info = array();
  $info['og_subgroups_workflow_ng_condition_has_family'] = array(
    '#label' => t('Group has subgroups family'),
    '#arguments' => array(
      'node' => array(
        '#entity' => 'node',
        '#label' => t('Group that will be checked if it has a subgroup parent'),
      ),
    ),
    '#description' => t('Evaluates to TRUE if the group has a family in the subgroups hierarchy. set the family relation to test (parent, children or syblings).'),
    '#module' => 'OG Subgroups',
  );
  return $info;
}

/**
 * Condition: Group has family.
 */
function og_subgroups_workflow_ng_condition_has_family($node, $settings) {
  $family = og_subgroups_get_family($node->nid, $settings['direction']);
  return (bool) $family;
}

/**
 * roup has family form.
 *
 * @ingroup forms.
 * @see og_subgroups_workflow_ng_condition_has_family_submit.
 */
function og_subgroups_workflow_ng_condition_has_family_form($settings = array(), $argument_info) {
  $form = array();
  $form['direction'] = array(
    '#type' => 'radios',
    '#title' => t('Family relation'),
    '#options' => array(
      'up' => 'parent',
      'down' => 'children',
      'side' => 'syblings',
    ),
    '#description' => t('Set which family relatives should be checked for presence.'),
    '#default_value' => $settings['direction'],
    '#required' => TRUE,
  );
  return $form;
}
function og_subgroups_workflow_ng_condition_has_family_submit($form_id, $form_values) {
  $settings = array(
    'direction' => $form_values['direction'],
  );
  return $settings;
}

Functions

Namesort descending Description
og_subgroups_action_info Implementation of hook_action_info().
og_subgroups_condition_info Implementation of hook_condition_info().
og_subgroups_workflow_ng_action_remove_hierarchy Action: Remove group from hierarchy.
og_subgroups_workflow_ng_action_set_parent Action: Set groups hierarchy.
og_subgroups_workflow_ng_condition_has_family Condition: Group has family.
og_subgroups_workflow_ng_condition_has_family_form roup has family form.
og_subgroups_workflow_ng_condition_has_family_submit