<?php

/**
 * Set default Q/A roles upon enable
 */
function commons_q_a_enable() {
  $revert = array(
    'commons_q_a' => array('og_features_permission'),
  );
  features_revert($revert);

  $groups = og_get_all_group();

  foreach ($groups AS $gid) {
    commons_groups_features_permission_rebuild('commons_q_a', $gid);
  }
}

/**
 * Update the Rate module settings for changes to the Up/Down widget.
 */
function commons_q_a_update_3100() {
    $revert = array(
      'commons_like' => array('variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Disable comments on Question nodes. Don't feature answers by default
 * (http://drupal.org/node/1921498).
 */
function commons_q_a_update_3101() {
    $revert = array(
      'commons_q_a' => array('variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Disable summary on Question/Answer nodes.
 */
function commons_q_a_update_3102() {
    $revert = array(
      'commons_q_a' => array('field_instance'),
  );
  features_revert($revert);
  return array();
}

/**
 * Update the Commons Q&A widget per http://drupal.org/node/1940644.
 */
function commons_q_a_update_3103() {
  // The Commons Q&A widget is defined via a hook_strongarm_alter()
  // implementation altering rate_widgets variable, defined by commons_like.
    $revert = array(
      'commons_like' => array('variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Disable comments on Answer nodes.
 */
function commons_q_a_update_3104() {
    $revert = array(
      'commons_q_a' => array('variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Link the 'Answer added' activity stream message to the Answer node as
 * displayed on the question per http://drupal.org/node/1946120.
 */
function commons_q_a_update_3105() {
    $revert = array(
      'commons_q_a' => array('field_instance', 'message_type', 'variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Use the standard user picture image size.
 */
function commons_q_a_update_3106() {
    $revert = array(
      'commons_q_a' => array('message_type'),
  );
  features_revert($revert);
  return array();
}

/**
 * Remove the "Like" widget from answer nodes, since they have a +/- widget.
 * Related issue: https://drupal.org/node/1935312.
 */
function commons_q_a_update_3107() {
  $revert = array(
    'commons_like' => array('variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Standardize Browsing Widget views.
 */
function commons_q_a_update_3108() {
  $revert = array(
    'commons_q_a' => array('views_view'),
  );
  features_revert($revert);
  return array();
}

/**
 * Display sticky content at top of lists.
 */
function commons_q_a_update_3109() {
  $revert = array(
    'commons_q_a' => array('views_view'),
  );
  features_revert($revert);
  return array();
}

/**
 * Indicate in the view that empty answers text is overridden by commons_q_a.
 */
function commons_q_a_update_3110() {
  $revert = array(
    'commons_q_a' => array('views_view'),
  );
  features_revert($revert);
  return array();
}

/**
 * Change the Answer URL alias to be a subpath of the question.
 */
function commons_q_a_update_3111() {
  $revert = array(
    'commons_q_a' => array('variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Improve the browsing widget empty text.
 */
function commons_q_a_update_3112() {
  $revert = array(
    'commons_q_a' => array('views_view'),
  );
  features_revert($revert);
  return array();
}

/**
 * Replace the title attribute with the title field in view displays.
 */
function commons_q_a_update_3113() {
  $revert = array(
    'commons_q_a' => array('views_view'),
  );
  features_revert($revert);
  return array();
}

/**
 * Fix URL aliases for group references
 */
function commons_q_a_update_3114() {
  $revert = array(
    'commons_q_a' => array('variable'),
  );
  features_revert($revert);
  return array();
}

/**
 * Standardize browsing widget field weights.
 */
function commons_q_a_update_3115() {
  $revert = array(
    'commons_q_a' => array('field_instance'),
  );
  features_revert($revert);
  return array();
}

/**
 * Accommodate changes to message definitions.
 */
function commons_q_a_update_3116() {
  $revert = array(
    'commons_q_a' => array('message_type'),
  );
  features_revert($revert);
  return array();
}
