You are here

function og_node_delete_move_memberships in Organic groups 6.2

Same name and namespace in other branches
  1. 6 og.module \og_node_delete_move_memberships()

Submit handler for group node delete form.

Move memberships to target group after a deletion of a group node. No access control.

1 string reference to 'og_node_delete_move_memberships'
og_node_delete_group_form in ./og.module
Form alter the node delete form for a group.

File

./og.module, line 2004
Code for the Organic Groups module.

Code

function og_node_delete_move_memberships($form, &$form_state) {
  if ($form_state['values']['verb'] == OG_DELETE_MOVE_NODES_MEMBERSHIPS) {
    $deleted_group_nid = $form_state['values']['nid'];
    $target_group_nid = $form_state['values']['target'];
    $sql = og_list_users_sql();
    $result = db_query($sql, $deleted_group_nid);
    $count = 0;
    while ($row = db_fetch_object($result)) {
      og_save_subscription($target_group_nid, $row->uid, array(
        'is_active' => 1,
      ));
      $count++;
    }
    drupal_set_message(format_plural($count, 'Moved 1 membership.', 'Moved @count memberships.'));
  }
}