{"action":"created","comment":{"url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/comments/29134914","id":29134914,"diff_hunk":"@@ -0,0 +1,834 @@\n+<?php\n+/**\n+ * @file\n+ * Custom manage page callbacks for the taxonomy module.\n+ */\n+\n+/**\n+ * Form builder for the taxonomy terms overview.\n+ *\n+ * Display a tree of all the terms in a vocabulary, with options to edit\n+ * each one. The form is made drag and drop by the theme function.\n+ *\n+ * @ingroup forms\n+ * @see taxonomy_overview_terms_submit()\n+ * @see theme_taxonomy_overview_terms()\n+ */\n+function c4m_features_og_manage_categories_overview_form($form, &$form_state) {\n+  $group = c4m_og_current_group();\n+  $vocabulary = c4m_og_vocab_load_group_vocabulary($group, 'c4m_vocab_category');\n+\n+  $form['#vocabulary'] = $vocabulary;\n+  $form['#group'] = $group;\n+  $form['#tree'] = TRUE;\n+  $form['#parent_fields'] = FALSE;\n+\n+  $parameters = drupal_get_query_parameters();\n+  // Check for confirmation forms.\n+  if (isset($parameters['delete'])) {\n+    // Delete confirmation form.\n+    return array_merge($form, c4m_features_og_manage_taxonomy_term_confirm_delete($form, $form_state, $parameters['delete']));\n+  }\n+  if (isset($parameters['reset_alphabetical'])) {\n+    // Reset alphabetically confirmation form.\n+    return c4m_taxonomy_vocabulary_confirm_reset_alphabetical($form, $form_state, $vocabulary->vid, $parameters['reset_alphabetical']);\n+  }\n+\n+  $delta = 0;\n+  $term_deltas = array();\n+  $menu_item = menu_get_item(current_path());\n+  $tree = $menu_item['path'] == 'manage/categories/types' ? taxonomy_get_tree($vocabulary->vid, 0, 1) : taxonomy_get_tree($vocabulary->vid);\n+  $term = current($tree);\n+  do {\n+    // In case this tree is completely empty.\n+    if (empty($term)) {\n+      break;\n+    }\n+    $delta++;\n+\n+    // Finally, if we've gotten down this far, we're rendering a term on this page.\n+    $term_deltas[$term->tid] = isset($term_deltas[$term->tid]) ? $term_deltas[$term->tid] + 1 : 0;\n+    $key = 'tid:' . $term->tid . ':' . $term_deltas[$term->tid];\n+\n+    $form['#first_tid'] = $term->tid;\n+    $current_page[$key] = $term;\n+  } while ($term = next($tree));\n+\n+  // If this form was already submitted once, it's probably hit a validation\n+  // error. Ensure the form is rebuilt in the same order as the user submitted.\n+  if (!empty($form_state['input'])) {\n+    $order = array_flip(array_keys($form_state['input'])); // Get the $_POST order.\n+    $current_page = array_merge($order, $current_page); // Update our form with the new order.\n+    foreach ($current_page as $key => $term) {\n+      // Verify this is a term for the current page and set at the current depth.\n+      if (is_array($form_state['input'][$key]) && is_numeric($form_state['input'][$key]['tid'])) {\n+        $current_page[$key]->depth = $form_state['input'][$key]['depth'];\n+      }\n+      else {\n+        unset($current_page[$key]);\n+      }\n+    }\n+  }\n+\n+  // Build the actual form.\n+  foreach ($current_page as $key => $term) {\n+    // Save the term for the current page so we don't have to load it a second time.\n+    $form[$key]['#term'] = (array) $term;\n+    if (isset($term->parents)) {\n+      $form[$key]['#term']['parent'] = $term->parent = $term->parents[0];\n+      unset($form[$key]['#term']['parents'], $term->parents);\n+    }\n+\n+    $form[$key]['view'] = array('#type' => 'link', '#title' => $term->name, '#href' => \"taxonomy/term/$term->tid\");\n+    if ($vocabulary->hierarchy < 2 && count($tree) > 1) {\n+      $form['#parent_fields'] = TRUE;\n+      $form[$key]['tid'] = array(\n+        '#type' => 'hidden',\n+        '#value' => $term->tid\n+      );\n+      $form[$key]['parent'] = array(\n+        '#type' => 'hidden',\n+        // Yes, default_value on a hidden. It needs to be changeable by the javascript.\n+        '#default_value' => $term->parent,\n+      );\n+      $form[$key]['depth'] = array(\n+        '#type' => 'hidden',\n+        // Same as above, the depth is modified by javascript, so it's a default_value.\n+        '#default_value' => $term->depth,\n+      );\n+    }\n+    $path = $menu_item['path'] == 'manage/categories/types' ? 'types' : '';\n+    $edit_path = $menu_item['path'] == 'manage/categories/types' ? 'type' : 'term';\n+    $form[$key]['edit'] = array('#type' => 'link', '#title' => t('Edit'), '#href' => 'manage/categories/' . $edit_path . '/' . $term->tid . '/edit', '#options' => array('query' => drupal_get_destination()));\n+    $form[$key]['delete'] = array('#type' => 'link', '#title' => t('Delete'), '#href' => 'manage/categories/' . $path, '#options' => array('query' => array('delete' => $term->tid)));\n+  }\n+\n+  $form['#empty_text'] = t('No terms available.');\n+\n+  if ($vocabulary->hierarchy < 2 && count($tree) > 1) {\n+    $form['actions'] = array('#type' => 'actions', '#tree' => FALSE);\n+    $form['actions']['submit'] = array(\n+      '#type' => 'submit',\n+      '#value' => t('Save')\n+    );\n+    $form_state['redirect'] = array($_GET['q'], (isset($_GET['page']) ? array('query' => array('page' => $_GET['page'])) : array()));\n+  }\n+\n+  if ($menu_item['path'] == 'manage/categories') {\n+    $form['actions']['new_category'] = array(\n+      '#type' => 'link',\n+      '#title' => t('Add new type of category'),\n+      '#href' => 'manage/categories/types',\n+      '#attributes' => array(\n+        'class' => array(\n+          'btn btn-default',\n+        ),\n+      ),\n+    );\n+  }\n+\n+  return $form;\n+}\n+\n+/**\n+ * @TODO: Add docs.\n+ */\n+function c4m_features_og_manage_categories_overview_form_validate($form, &$form_state) {\n+  // Add validate here.\n+}\n+\n+/**\n+ * Form builder for the term delete form.\n+ *\n+ * @ingroup forms\n+ * @see taxonomy_term_confirm_delete_submit()\n+ */\n+function c4m_features_og_manage_taxonomy_term_confirm_delete($form, &$form_state, $tid) {\n+  $term = taxonomy_term_load($tid);\n+  // Always provide entity id in the same form key as in the entity edit form.\n+  $form['tid'] = array('#type' => 'value', '#value' => $tid);\n+\n+  $form['#term'] = $term;\n+  $form['type'] = array('#type' => 'value', '#value' => 'term');\n+  $form['name'] = array('#type' => 'value', '#value' => $term->name);\n+  $form['vocabulary_machine_name'] = array('#type' => 'value', '#value' => $term->vocabulary_machine_name);\n+  $form['delete'] = array('#type' => 'value', '#value' => TRUE);\n+  $menu_item = menu_get_item(current_path());\n+  $path = $menu_item['path'] == 'manage/categories/types' ? 'types' : '';\n+  return confirm_form($form,\n+    t('Are you sure you want to delete the term %title?',\n+      array('%title' => $term->name)),\n+    'manage/categories/' . $path,\n+    '<div class=\"question\">'\n+    . t('Are you sure you want to delete the term %title?', array('%title' => $term->name))\n+    . '</div>'\n+    . t('Deleting a term will delete all its children if there are any. This action cannot be undone.'),\n+    t('Delete'),\n+    t('Cancel'));\n+}\n+\n+/**\n+ * Submit handler to delete a term after confirmation.\n+ *\n+ * @see taxonomy_term_confirm_delete_submit()\n+ */\n+function c4m_features_og_manage_taxonomy_term_confirm_delete_submit($form, &$form_state) {\n+  taxonomy_term_delete($form_state['values']['tid']);\n+  taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']);\n+  drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));\n+  watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);\n+  $menu_item = menu_get_item(current_path());\n+  $path = $menu_item['path'] == 'manage/categories/types' ? 'types' : '';\n+  $form_state['redirect'] = 'manage/categories/' . $path;\n+  cache_clear_all();\n+  return;\n+}\n+\n+/**\n+ * Form builder to confirm resetting a terms under a specific category to alphabetical order.\n+ *\n+ * @ingroup forms\n+ * @see taxonomy_vocabulary_confirm_reset_alphabetical()\n+ */\n+function c4m_taxonomy_vocabulary_confirm_reset_alphabetical($form, &$form_state, $vid, $tid) {\n+  $vocabulary = taxonomy_vocabulary_load($vid);\n+  $form['type'] = array('#type' => 'value', '#value' => 'vocabulary');\n+  $form['vid'] = array('#type' => 'value', '#value' => $vid);\n+  $form['machine_name'] = array('#type' => 'value', '#value' => $vocabulary->machine_name);\n+  $form['reset_alphabetical'] = array('#type' => 'value', '#value' => TRUE);\n+  $path = $tid ? $vocabulary->machine_name : 'types';\n+\n+  if ($tid) {\n+    $term = taxonomy_term_load($tid);\n+    $form['parent_tid'] = array('#type' => 'value', '#value' => $tid);\n+    $form['name'] = array('#type' => 'value', '#value' => $term->name);\n+\n+    return confirm_form($form,\n+      t('Are you sure you want to reset the children of the term %title to alphabetical order?',\n+        array('%title' => $term->name)),\n+      'manage/categories/' . $path,\n+      '<div class=\"question\">'\n+      . t('Are you sure you want to reset the children of the term %title to alphabetical order?',\n+        array('%title' => $term->name))\n+      . '</div>'\n+      . t('Resetting the children of the term %title will discard all custom ordering and sort items alphabetically.',\n+        array('%title' => $term->name)),\n+      t('Reset to alphabetical'),\n+      t('Cancel'));\n+  }\n+  else {\n+    return confirm_form($form,\n+      t('Are you sure you want to reset the Categories to alphabetical order?'),\n+      'manage/categories/' . $path,\n+      '<div class=\"question\">'\n+      . t('Are you sure you want to reset the Categories to alphabetical order?')\n+      . '</div>'\n+      . t('Resetting the the Categories will discard all custom ordering and sort items alphabetically.'),\n+      t('Reset to alphabetical'),\n+      t('Cancel'));\n+  }\n+}\n+\n+/**\n+ * Submit handler to reset a specific category's children to alphabetical order after confirmation.\n+ *\n+ * @see c4m_taxonomy_vocabulary_confirm_reset_alphabetical()\n+ */\n+function c4m_taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state) {\n+  $params = array(\n+    ':weight' => 0,\n+    ':vid' => $form_state['values']['vid'],\n+  );\n+  $condition = '';\n+  if (isset($form_state['values']['parent_tid'])) {\n+    $params[':parent_tid'] = $form_state['values']['parent_tid'];\n+    $condition = ' AND h.parent = :parent_tid';\n+  }\n+\n+  db_query(\n+    'UPDATE {taxonomy_term_data} AS d ' .\n+    'JOIN {taxonomy_term_hierarchy} AS h ' .\n+    'ON d.tid = h.tid ' .\n+    'SET d.weight = :weight ' .\n+    'WHERE d.vid = :vid' .\n+    $condition,\n+    $params\n+  );\n+  $menu_item = menu_get_item(current_path());\n+  $path = $menu_item['path'] == 'manage/categories/types' ? 'types' : '';\n+\n+  if (isset($form_state['values']['name'])) {\n+    drupal_set_message(t('Reset category %name children to alphabetical order.', array('%name' => $form_state['values']['name'])));\n+    watchdog('taxonomy', 'Reset category %name children to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);\n+  }\n+  else {\n+    drupal_set_message(t('Reset Categories to alphabetical order.'));\n+    watchdog('taxonomy', 'Reset Categories to alphabetical order.', WATCHDOG_NOTICE);\n+  }\n+  $form_state['redirect'] = 'manage/categories/' . $path;\n+}\n+\n+/**\n+ * @see taxonomy_overview_terms_submit()\n+ */\n+function c4m_features_og_manage_categories_overview_form_submit($form, &$form_state) {\n+  if ($form_state['triggering_element']['#value'] == t('Delete')) {\n+    // Execute the term deletion.\n+    if ($form_state['values']['delete'] === TRUE) {\n+      c4m_features_og_manage_taxonomy_term_confirm_delete_submit($form, $form_state);\n+      return;\n+    }\n+  }\n+\n+  if ($form_state['triggering_element']['#value'] == t('Reset to alphabetical')) {\n+    // Execute the term reset alphabetical.\n+    if ($form_state['values']['reset_alphabetical'] === TRUE) {\n+      c4m_taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, $form_state);\n+      return;\n+    }\n+  }\n+\n+  $vocabulary = $form['#vocabulary'];\n+  $hierarchy = 0; // Update the current hierarchy type as we go.\n+\n+  $changed_terms = array();\n+\n+  $menu_item = menu_get_item(current_path());\n+  $tree = $menu_item['path'] == 'manage/categories/types' ? taxonomy_get_tree($vocabulary->vid, 0, 1) : taxonomy_get_tree($vocabulary->vid);\n+\n+  if (empty($tree)) {\n+    return;\n+  }\n+\n+  // Build a list of all terms that need to be updated on previous pages.\n+  $weight = 0;\n+  $term = (array) $tree[0];\n+  while ($term['tid'] != $form['#first_tid']) {\n+    if ($term['parents'][0] == 0 && $term['weight'] != $weight) {\n+      $term['parent'] = $term['parents'][0];\n+      $term['weight'] = $weight;\n+      $changed_terms[$term['tid']] = $term;\n+    }\n+    $weight++;\n+    $hierarchy = $term['parents'][0] != 0 ? 1 : $hierarchy;\n+    $term = (array) $tree[$weight];\n+  }\n+\n+  // Renumber the current page weights and assign any new parents.\n+  $level_weights = array();\n+  foreach ($form_state['values'] as $tid => $values) {\n+    if (isset($form[$tid]['#term'])) {\n+      $term = $form[$tid]['#term'];\n+      // Give terms at the root level a weight in sequence with terms on previous pages.\n+      if ($values['parent'] == 0 && $term['weight'] != $weight) {\n+        $term['weight'] = $weight;\n+        $changed_terms[$term['tid']] = $term;\n+      }\n+      // Terms not at the root level can safely start from 0 because they're all on this page.\n+      elseif ($values['parent'] > 0) {\n+        $level_weights[$values['parent']] = isset($level_weights[$values['parent']]) ? $level_weights[$values['parent']] + 1 : 0;\n+        if ($level_weights[$values['parent']] != $term['weight']) {\n+          $term['weight'] = $level_weights[$values['parent']];\n+          $changed_terms[$term['tid']] = $term;\n+        }\n+      }\n+      $hierarchy = $term['parent'] != 0 ? 1 : $hierarchy;\n+      $weight++;\n+    }\n+  }\n+\n+  // Build a list of all terms that need to be updated on following pages.\n+  for ($weight; $weight < count($tree); $weight++) {\n+    $term = (array) $tree[$weight];\n+    if ($term['parents'][0] == 0 && $term['weight'] != $weight) {\n+      $term['parent'] = $term['parents'][0];\n+      $term['weight'] = $weight;\n+      $changed_terms[$term['tid']] = $term;\n+    }\n+    $hierarchy = $term['parents'][0] != 0 ? 1 : $hierarchy;\n+  }\n+  // Save all updated terms.\n+  foreach ($changed_terms as $changed) {\n+    $term = (object) $changed;\n+    // Update term_hierarchy and term_data directly since we don't have a\n+    // fully populated term object to save.\n+    db_update('taxonomy_term_hierarchy')\n+      ->fields(array('parent' => $term->parent))\n+      ->condition('tid', $term->tid, '=')\n+      ->execute();\n+\n+    db_update('taxonomy_term_data')\n+      ->fields(array('weight' => $term->weight))\n+      ->condition('tid', $term->tid, '=')\n+      ->execute();\n+  }\n+\n+  // Update the vocabulary hierarchy to flat or single hierarchy.\n+  if ($vocabulary->hierarchy != $hierarchy) {\n+    $vocabulary->hierarchy = $hierarchy;\n+    taxonomy_vocabulary_save($vocabulary);\n+  }\n+  drupal_set_message(t('The configuration options have been saved.'));\n+}\n+\n+/**\n+ * Form function for the category type edit form.\n+ *\n+ * To avoid duplicated code, using the term edit form to build this form,\n+ * as it's almost the same form, Just unset the parent fields and change the title and description.\n+ *\n+ * @ingroup forms\n+ * @see taxonomy_form_term()\n+ */\n+function c4m_features_og_manage_categories_type_form($form, &$form_state, $tid) {\n+  $form = c4m_features_og_manage_categories_term_form($form, $form_state, $tid);\n+  unset($form['title']);\n+  unset($form['description']);\n+  unset($form['parent']);\n+\n+  $title['element'] = array(\n+    '#tag' => 'h2',\n+    '#attributes' => array(\n+      'class' => array('type-edit-title-text'),\n+    ),\n+    '#value' => t('Manage types of category'),\n+  );\n+\n+  $description['element'] = array(\n+    '#tag' => 'h4',\n+    '#attributes' => array(\n+      'class' => array('type-edit-description-text'),\n+    ),\n+    '#value' => t('Change the types of category of this Group.'),\n+  );\n+\n+  $form['title'] = array(\n+    '#markup' => theme_html_tag($title),\n+    '#weight' => -10,\n+  );\n+\n+  $form['description'] = array(\n+    '#markup' => theme_html_tag($description),\n+    '#weight' => -5,\n+  );\n+  return $form;\n+}\n+\n+/**\n+ * Validation handler for the custom type form.\n+ *\n+ * @see c4m_features_og_manage_categories_type_form()\n+ */\n+function c4m_features_og_manage_categories_type_form_validate($form, &$form_state) {\n+  entity_form_field_validate('taxonomy_term', $form, $form_state);\n+}\n+\n+/**\n+ * Submit handler to update a type.\n+ *\n+ * @see c4m_features_og_manage_categories_type_form()\n+ */\n+function c4m_features_og_manage_categories_type_form_submit($form, &$form_state) {\n+  if ($form_state['triggering_element']['#value'] == t('Delete')) {\n+    // Execute the term deletion.\n+    if ($form_state['values']['delete'] === TRUE) {\n+      c4m_features_og_manage_taxonomy_term_confirm_delete_submit($form, $form_state);\n+      return;\n+    }\n+    // Rebuild the form to confirm term deletion.\n+    $form_state['rebuild'] = TRUE;\n+    $form_state['confirm_delete'] = TRUE;\n+    return;\n+  }\n+  if ($form_state['triggering_element']['#value'] == t('Cancel')) {\n+    return;\n+  }\n+\n+  $term = c4m_features_og_manage_taxonomy_form_term_submit_build_taxonomy_term($form, $form_state);\n+\n+  taxonomy_term_save($term);\n+  drupal_set_message(t('Updated category type %term.', array('%term' => $term->name)));\n+  watchdog('taxonomy', 'Updated category type %term.', array('%term' => $term->name), WATCHDOG_NOTICE, l(t('edit'), 'manage/categories/type/' . $term->tid . '/edit'));\n+  // Clear the page and block caches to avoid stale data.\n+  cache_clear_all();\n+}\n+\n+/**\n+ * Form function for the term edit form.\n+ *\n+ * @ingroup forms\n+ * @see taxonomy_form_term()\n+ */\n+function c4m_features_og_manage_categories_term_form($form, &$form_state, $tid) {\n+  // Validate if the given term is valid.\n+  if(!$term = taxonomy_term_load($tid)) {\n+    drupal_set_message(t('No valid term was given.'));\n+    $form_state['redirect'] = 'manage/categories';\n+    drupal_redirect_form($form_state);\n+  }\n+\n+  $group = c4m_og_current_group();\n+  $vocabulary = c4m_og_vocab_load_group_vocabulary($group, 'c4m_vocab_category');\n+\n+  // Validate if the given term belongs to the current group.\n+  if(!_og_vocab_term_exists_in_vocab($term->name, $vocabulary->vid)) {\n+    drupal_set_message(t('The term \"%name\" does not belong to the current group.', array('%name' => $term->name)));\n+    $form_state['redirect'] = 'manage/categories';\n+    drupal_redirect_form($form_state);\n+  }\n+\n+  // Check for confirmation forms.\n+  if (isset($form_state['confirm_delete'])) {\n+    return array_merge($form, c4m_features_og_manage_taxonomy_term_confirm_delete($form, $form_state, $term->tid));\n+  }\n+\n+  $parent = array_keys(taxonomy_get_parents($term->tid));\n+  $form['#term'] = (array) $term;\n+  $form['#term']['parent'] = $parent;\n+  $form['#vocabulary'] = $vocabulary;\n+  $form_state['term'] = $term;\n+\n+  $tree = taxonomy_get_tree($vocabulary->vid, 0, 1);\n+  $options = array();\n+  if (empty($parent)) {\n+    $parent = array(0);\n+  }\n+\n+  foreach ($tree as $item) {\n+    $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;\n+  }\n+\n+  $title['element'] = array(\n+    '#tag' => 'h2',\n+    '#attributes' => array(\n+      'class' => array('term-edit-title-text'),\n+    ),\n+    '#value' => t('Manage Group categories'),\n+  );\n+\n+  $description['element'] = array(\n+    '#tag' => 'h4',\n+    '#attributes' => array(\n+      'class' => array('term-edit-description-text'),\n+    ),\n+    '#value' => t('Change the category term of this Group.'),\n+  );\n+\n+  $form['title'] = array(\n+    '#markup' => theme_html_tag($title),\n+    '#weight' => -10,\n+  );\n+\n+  $form['description'] = array(\n+    '#markup' => theme_html_tag($description),\n+    '#weight' => -5,\n+  );\n+\n+  $form['parent'] = array(\n+    '#type' => 'radios',\n+    '#title' => t('Type of category'),\n+    '#options' => $options,\n+    '#default_value' => reset($parent),\n+    '#required' => TRUE,\n+    '#weight' => 0,\n+  );\n+\n+  $form['name'] = array(\n+    '#type' => 'textfield',\n+    '#title' => t('Term name'),\n+    '#default_value' => $term->name,\n+    '#maxlength' => 255,\n+    '#required' => TRUE,\n+    '#weight' => 5,\n+  );\n+\n+  $form['vocabulary_machine_name'] = array(\n+    '#type' => 'value',\n+    '#value' => isset($term->vocabulary_machine_name) ? $term->vocabulary_machine_name : $vocabulary->name,\n+  );\n+\n+  $form['vid'] = array(\n+    '#type' => 'value',\n+    '#value' => $vocabulary->vid,\n+  );\n+  $form['tid'] = array(\n+    '#type' => 'value',\n+    '#value' => $term->tid,\n+  );\n+\n+  $form['actions'] = array('#type' => 'actions');\n+  $form['actions']['submit'] = array(\n+    '#type' => 'submit',\n+    '#value' => t('Save'),\n+    '#weight' => 10,\n+  );\n+\n+  $form['actions']['cancel'] = array(\n+    '#type' => 'submit',\n+    '#value' => t('Cancel'),\n+    '#weight' => 15,\n+  );\n+\n+  $form['actions']['delete'] = array(\n+    '#type' => 'submit',\n+    '#value' => t('Delete'),\n+    '#weight' => 20,\n+  );\n+\n+  return $form;\n+}\n+\n+/**\n+ * Validation handler for the custom term form.\n+ *\n+ * @see c4m_features_og_manage_categories_term_form()\n+ */\n+function c4m_features_og_manage_categories_term_form_validate($form, &$form_state) {\n+  entity_form_field_validate('taxonomy_term', $form, $form_state);\n+}\n+\n+/**\n+ * Submit handler to update a term.\n+ *\n+ * @see c4m_features_og_manage_categories_term_form()\n+ */\n+function c4m_features_og_manage_categories_term_form_submit($form, &$form_state) {\n+  if ($form_state['triggering_element']['#value'] == t('Delete')) {\n+    // Execute the term deletion.\n+    if ($form_state['values']['delete'] === TRUE) {\n+      $group = c4m_og_current_group();\n+      $form['#vocabulary'] = c4m_og_vocab_load_group_vocabulary($group, 'c4m_vocab_category');\n+      c4m_features_og_manage_taxonomy_term_confirm_delete_submit($form, $form_state);\n+      return;\n+    }\n+    // Rebuild the form to confirm term deletion.\n+    $form_state['rebuild'] = TRUE;\n+    $form_state['confirm_delete'] = TRUE;\n+    return;\n+  }\n+  if ($form_state['triggering_element']['#value'] == t('Cancel')) {","path":"capacity4more/modules/c4m/features_og/c4m_features_og_manage/c4m_manage_categories.inc","position":609,"original_position":609,"commit_id":"621fe528d1b5ba1c97cc009e70a620f50f0cff0f","original_commit_id":"621fe528d1b5ba1c97cc009e70a620f50f0cff0f","user":{"login":"zero2one","id":133124,"avatar_url":"https://avatars.githubusercontent.com/u/133124?v=3","gravatar_id":"","url":"https://api.github.com/users/zero2one","html_url":"https://github.com/zero2one","followers_url":"https://api.github.com/users/zero2one/followers","following_url":"https://api.github.com/users/zero2one/following{/other_user}","gists_url":"https://api.github.com/users/zero2one/gists{/gist_id}","starred_url":"https://api.github.com/users/zero2one/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zero2one/subscriptions","organizations_url":"https://api.github.com/users/zero2one/orgs","repos_url":"https://api.github.com/users/zero2one/repos","events_url":"https://api.github.com/users/zero2one/events{/privacy}","received_events_url":"https://api.github.com/users/zero2one/received_events","type":"User","site_admin":false},"body":"No need for this if you use the [confirm_form](https://api.drupal.org/api/drupal/modules%21system%21system.module/function/confirm_form/7).\r\n\r\nParameters\r\n\r\n* $form: Additional elements to add to the form. These can be regular form elements, #value elements, etc., and their values will be available to the submit handler.\r\n* $question: The question to ask the user (e.g. \"Are you sure you want to delete the block <em>foo</em>?\"). The page title will be set to this value.\r\n* **$path: The page to go to if the user cancels the action**. This can be either:\r\n  * A string containing a Drupal path.\r\n  * An associative array with a 'path' key. Additional array values are passed as the $options parameter to l().\r\n  * If the 'destination' query parameter is set in the URL when viewing a confirmation form, that value will be used instead of $path.\r\n* $description: Additional text to display. Defaults to t('This action cannot be undone.').\r\n* $yes: A caption for the button that confirms the action (e.g. \"Delete\", \"Replace\", ...). Defaults to t('Confirm').\r\n* $no: A caption for the link which cancels the action (e.g. \"Cancel\"). Defaults to t('Cancel').\r\n* $name: The internal name used to refer to the confirmation item.","created_at":"2015-04-27T10:12:15Z","updated_at":"2015-04-27T10:12:15Z","html_url":"https://github.com/capacity4dev/capacity4more/pull/581#discussion_r29134914","pull_request_url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581","_links":{"self":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/comments/29134914"},"html":{"href":"https://github.com/capacity4dev/capacity4more/pull/581#discussion_r29134914"},"pull_request":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581"}}},"pull_request":{"url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581","id":32645123,"html_url":"https://github.com/capacity4dev/capacity4more/pull/581","diff_url":"https://github.com/capacity4dev/capacity4more/pull/581.diff","patch_url":"https://github.com/capacity4dev/capacity4more/pull/581.patch","issue_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues/581","number":581,"state":"open","locked":false,"title":"WIP: CFD-384 : Group management Categories : Overview screen.","user":{"login":"nader77","id":7369740,"avatar_url":"https://avatars.githubusercontent.com/u/7369740?v=3","gravatar_id":"","url":"https://api.github.com/users/nader77","html_url":"https://github.com/nader77","followers_url":"https://api.github.com/users/nader77/followers","following_url":"https://api.github.com/users/nader77/following{/other_user}","gists_url":"https://api.github.com/users/nader77/gists{/gist_id}","starred_url":"https://api.github.com/users/nader77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nader77/subscriptions","organizations_url":"https://api.github.com/users/nader77/orgs","repos_url":"https://api.github.com/users/nader77/repos","events_url":"https://api.github.com/users/nader77/events{/privacy}","received_events_url":"https://api.github.com/users/nader77/received_events","type":"User","site_admin":false},"body":"#571","created_at":"2015-04-05T06:56:00Z","updated_at":"2015-04-27T10:12:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c5673c492585758711fc9819d8e7f0528d02e2f8","assignee":{"login":"nader77","id":7369740,"avatar_url":"https://avatars.githubusercontent.com/u/7369740?v=3","gravatar_id":"","url":"https://api.github.com/users/nader77","html_url":"https://github.com/nader77","followers_url":"https://api.github.com/users/nader77/followers","following_url":"https://api.github.com/users/nader77/following{/other_user}","gists_url":"https://api.github.com/users/nader77/gists{/gist_id}","starred_url":"https://api.github.com/users/nader77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nader77/subscriptions","organizations_url":"https://api.github.com/users/nader77/orgs","repos_url":"https://api.github.com/users/nader77/repos","events_url":"https://api.github.com/users/nader77/events{/privacy}","received_events_url":"https://api.github.com/users/nader77/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581/commits","review_comments_url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581/comments","review_comment_url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/comments{/number}","comments_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues/581/comments","statuses_url":"https://api.github.com/repos/capacity4dev/capacity4more/statuses/621fe528d1b5ba1c97cc009e70a620f50f0cff0f","head":{"label":"capacity4dev:feature/CFD-384-GMC_overview_screen","ref":"feature/CFD-384-GMC_overview_screen","sha":"621fe528d1b5ba1c97cc009e70a620f50f0cff0f","user":{"login":"capacity4dev","id":6919578,"avatar_url":"https://avatars.githubusercontent.com/u/6919578?v=3","gravatar_id":"","url":"https://api.github.com/users/capacity4dev","html_url":"https://github.com/capacity4dev","followers_url":"https://api.github.com/users/capacity4dev/followers","following_url":"https://api.github.com/users/capacity4dev/following{/other_user}","gists_url":"https://api.github.com/users/capacity4dev/gists{/gist_id}","starred_url":"https://api.github.com/users/capacity4dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capacity4dev/subscriptions","organizations_url":"https://api.github.com/users/capacity4dev/orgs","repos_url":"https://api.github.com/users/capacity4dev/repos","events_url":"https://api.github.com/users/capacity4dev/events{/privacy}","received_events_url":"https://api.github.com/users/capacity4dev/received_events","type":"Organization","site_admin":false},"repo":{"id":18283391,"name":"capacity4more","full_name":"capacity4dev/capacity4more","owner":{"login":"capacity4dev","id":6919578,"avatar_url":"https://avatars.githubusercontent.com/u/6919578?v=3","gravatar_id":"","url":"https://api.github.com/users/capacity4dev","html_url":"https://github.com/capacity4dev","followers_url":"https://api.github.com/users/capacity4dev/followers","following_url":"https://api.github.com/users/capacity4dev/following{/other_user}","gists_url":"https://api.github.com/users/capacity4dev/gists{/gist_id}","starred_url":"https://api.github.com/users/capacity4dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capacity4dev/subscriptions","organizations_url":"https://api.github.com/users/capacity4dev/orgs","repos_url":"https://api.github.com/users/capacity4dev/repos","events_url":"https://api.github.com/users/capacity4dev/events{/privacy}","received_events_url":"https://api.github.com/users/capacity4dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/capacity4dev/capacity4more","description":"A Drupal 7 powered distribution providing a community platform to share knowledge.","fork":false,"url":"https://api.github.com/repos/capacity4dev/capacity4more","forks_url":"https://api.github.com/repos/capacity4dev/capacity4more/forks","keys_url":"https://api.github.com/repos/capacity4dev/capacity4more/keys{/key_id}","collaborators_url":"https://api.github.com/repos/capacity4dev/capacity4more/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/capacity4dev/capacity4more/teams","hooks_url":"https://api.github.com/repos/capacity4dev/capacity4more/hooks","issue_events_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues/events{/number}","events_url":"https://api.github.com/repos/capacity4dev/capacity4more/events","assignees_url":"https://api.github.com/repos/capacity4dev/capacity4more/assignees{/user}","branches_url":"https://api.github.com/repos/capacity4dev/capacity4more/branches{/branch}","tags_url":"https://api.github.com/repos/capacity4dev/capacity4more/tags","blobs_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/refs{/sha}","trees_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/trees{/sha}","statuses_url":"https://api.github.com/repos/capacity4dev/capacity4more/statuses/{sha}","languages_url":"https://api.github.com/repos/capacity4dev/capacity4more/languages","stargazers_url":"https://api.github.com/repos/capacity4dev/capacity4more/stargazers","contributors_url":"https://api.github.com/repos/capacity4dev/capacity4more/contributors","subscribers_url":"https://api.github.com/repos/capacity4dev/capacity4more/subscribers","subscription_url":"https://api.github.com/repos/capacity4dev/capacity4more/subscription","commits_url":"https://api.github.com/repos/capacity4dev/capacity4more/commits{/sha}","git_commits_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/commits{/sha}","comments_url":"https://api.github.com/repos/capacity4dev/capacity4more/comments{/number}","issue_comment_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues/comments{/number}","contents_url":"https://api.github.com/repos/capacity4dev/capacity4more/contents/{+path}","compare_url":"https://api.github.com/repos/capacity4dev/capacity4more/compare/{base}...{head}","merges_url":"https://api.github.com/repos/capacity4dev/capacity4more/merges","archive_url":"https://api.github.com/repos/capacity4dev/capacity4more/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/capacity4dev/capacity4more/downloads","issues_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues{/number}","pulls_url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls{/number}","milestones_url":"https://api.github.com/repos/capacity4dev/capacity4more/milestones{/number}","notifications_url":"https://api.github.com/repos/capacity4dev/capacity4more/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/capacity4dev/capacity4more/labels{/name}","releases_url":"https://api.github.com/repos/capacity4dev/capacity4more/releases{/id}","created_at":"2014-03-31T06:03:43Z","updated_at":"2015-04-24T05:25:16Z","pushed_at":"2015-04-27T09:43:38Z","git_url":"git://github.com/capacity4dev/capacity4more.git","ssh_url":"git@github.com:capacity4dev/capacity4more.git","clone_url":"https://github.com/capacity4dev/capacity4more.git","svn_url":"https://github.com/capacity4dev/capacity4more","homepage":null,"size":53598,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":6,"default_branch":"develop"}},"base":{"label":"capacity4dev:develop","ref":"develop","sha":"7b04bdc57a7e49c1cdb436b75a306d21a01f31f9","user":{"login":"capacity4dev","id":6919578,"avatar_url":"https://avatars.githubusercontent.com/u/6919578?v=3","gravatar_id":"","url":"https://api.github.com/users/capacity4dev","html_url":"https://github.com/capacity4dev","followers_url":"https://api.github.com/users/capacity4dev/followers","following_url":"https://api.github.com/users/capacity4dev/following{/other_user}","gists_url":"https://api.github.com/users/capacity4dev/gists{/gist_id}","starred_url":"https://api.github.com/users/capacity4dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capacity4dev/subscriptions","organizations_url":"https://api.github.com/users/capacity4dev/orgs","repos_url":"https://api.github.com/users/capacity4dev/repos","events_url":"https://api.github.com/users/capacity4dev/events{/privacy}","received_events_url":"https://api.github.com/users/capacity4dev/received_events","type":"Organization","site_admin":false},"repo":{"id":18283391,"name":"capacity4more","full_name":"capacity4dev/capacity4more","owner":{"login":"capacity4dev","id":6919578,"avatar_url":"https://avatars.githubusercontent.com/u/6919578?v=3","gravatar_id":"","url":"https://api.github.com/users/capacity4dev","html_url":"https://github.com/capacity4dev","followers_url":"https://api.github.com/users/capacity4dev/followers","following_url":"https://api.github.com/users/capacity4dev/following{/other_user}","gists_url":"https://api.github.com/users/capacity4dev/gists{/gist_id}","starred_url":"https://api.github.com/users/capacity4dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capacity4dev/subscriptions","organizations_url":"https://api.github.com/users/capacity4dev/orgs","repos_url":"https://api.github.com/users/capacity4dev/repos","events_url":"https://api.github.com/users/capacity4dev/events{/privacy}","received_events_url":"https://api.github.com/users/capacity4dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/capacity4dev/capacity4more","description":"A Drupal 7 powered distribution providing a community platform to share knowledge.","fork":false,"url":"https://api.github.com/repos/capacity4dev/capacity4more","forks_url":"https://api.github.com/repos/capacity4dev/capacity4more/forks","keys_url":"https://api.github.com/repos/capacity4dev/capacity4more/keys{/key_id}","collaborators_url":"https://api.github.com/repos/capacity4dev/capacity4more/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/capacity4dev/capacity4more/teams","hooks_url":"https://api.github.com/repos/capacity4dev/capacity4more/hooks","issue_events_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues/events{/number}","events_url":"https://api.github.com/repos/capacity4dev/capacity4more/events","assignees_url":"https://api.github.com/repos/capacity4dev/capacity4more/assignees{/user}","branches_url":"https://api.github.com/repos/capacity4dev/capacity4more/branches{/branch}","tags_url":"https://api.github.com/repos/capacity4dev/capacity4more/tags","blobs_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/refs{/sha}","trees_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/trees{/sha}","statuses_url":"https://api.github.com/repos/capacity4dev/capacity4more/statuses/{sha}","languages_url":"https://api.github.com/repos/capacity4dev/capacity4more/languages","stargazers_url":"https://api.github.com/repos/capacity4dev/capacity4more/stargazers","contributors_url":"https://api.github.com/repos/capacity4dev/capacity4more/contributors","subscribers_url":"https://api.github.com/repos/capacity4dev/capacity4more/subscribers","subscription_url":"https://api.github.com/repos/capacity4dev/capacity4more/subscription","commits_url":"https://api.github.com/repos/capacity4dev/capacity4more/commits{/sha}","git_commits_url":"https://api.github.com/repos/capacity4dev/capacity4more/git/commits{/sha}","comments_url":"https://api.github.com/repos/capacity4dev/capacity4more/comments{/number}","issue_comment_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues/comments{/number}","contents_url":"https://api.github.com/repos/capacity4dev/capacity4more/contents/{+path}","compare_url":"https://api.github.com/repos/capacity4dev/capacity4more/compare/{base}...{head}","merges_url":"https://api.github.com/repos/capacity4dev/capacity4more/merges","archive_url":"https://api.github.com/repos/capacity4dev/capacity4more/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/capacity4dev/capacity4more/downloads","issues_url":"https://api.github.com/repos/capacity4dev/capacity4more/issues{/number}","pulls_url":"https://api.github.com/repos/capacity4dev/capacity4more/pulls{/number}","milestones_url":"https://api.github.com/repos/capacity4dev/capacity4more/milestones{/number}","notifications_url":"https://api.github.com/repos/capacity4dev/capacity4more/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/capacity4dev/capacity4more/labels{/name}","releases_url":"https://api.github.com/repos/capacity4dev/capacity4more/releases{/id}","created_at":"2014-03-31T06:03:43Z","updated_at":"2015-04-24T05:25:16Z","pushed_at":"2015-04-27T09:43:38Z","git_url":"git://github.com/capacity4dev/capacity4more.git","ssh_url":"git@github.com:capacity4dev/capacity4more.git","clone_url":"https://github.com/capacity4dev/capacity4more.git","svn_url":"https://github.com/capacity4dev/capacity4more","homepage":null,"size":53598,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":6,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581"},"html":{"href":"https://github.com/capacity4dev/capacity4more/pull/581"},"issue":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/issues/581"},"comments":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/issues/581/comments"},"review_comments":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581/comments"},"review_comment":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/pulls/581/commits"},"statuses":{"href":"https://api.github.com/repos/capacity4dev/capacity4more/statuses/621fe528d1b5ba1c97cc009e70a620f50f0cff0f"}}}}