You are here

function oa_core_form_node_delete_confirm_alter in Open Atrium Core 7.2

Implements hook_form_alter().

File

./oa_core.module, line 599

Code

function oa_core_form_node_delete_confirm_alter(&$form, $form_state) {
  $form['#submit'][] = 'oa_core_node_delete_redirect';

  /**
   * Organic group itself has some functionality for how to handle content on
   * group deletion.
   *
   * By default, it'll delete the og_membership table entries for that group.
   *
   * If variable og_use_queue is configured to true:
   * * It'll delete the membership via a queue job.
   * * It'll delete the content of the group if $entity->og_orphans['delete'] is
   *   TRUE or variable og_orphans_delete is set to true
   * * It'll move the content of the group if $entity->og_orphans['move'] is set
   * to  an array containing group_type and gid of the group to move to.
   *
   * Use og_use_queue and og_orphans_delete are configurable via the OG UI.
   *
   * All it's deletion logic can be bypassed via setting:
   * $entity->skip_og_membership_delete_by_group = TRUE
   */
  if (variable_get('og_use_queue', FALSE) && ($orphans = oa_core_get_orphans('node', $form['#node']->nid))) {
    $form['oa_core_orphans'] = array(
      '#title' => t('Orphan Content'),
      '#description' => t('How to handle orphan content (content that is a member of this group but no others)'),
      '#type' => 'radios',
      '#options' => array(
        'nothing' => t('Orphan (remove membership but otherwise leave content alone)'),
        'delete' => t('Delete'),
        'move' => t('Move'),
      ),
      '#default_value' => 'nothing',
    );
    $form['oa_core_orphans_og_group_ref'] = array(
      '#type' => 'og_group_ref',
      '#title' => t('Space'),
      '#default_value' => array(),
      '#states' => array(
        'visible' => array(
          ':input[name="oa_core_orphans"]' => array(
            'value' => 'move',
          ),
        ),
      ),
    );
    $form['#validate'][] = 'oa_core_form_node_delete_confirm_validate';
  }
}