I've selected some flags for my content types. When I try to export my settings, the types are ignored in hook_flag_default_flags().
It happens when exporting a feature, but also using the Export link in the Flags interface.

Any thoughts?

Comments

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

Works for me:

$flags = array();
// Exported flag: "Node global".
$flags['node_global'] = array(
  'content_type' => 'node',
  'title' => 'Node global',
  'global' => '1',
  'types' => array(
    0 => 'article',
    1 => 'page',
  ),
  'flag_short' => 'flag',
  'flag_long' => '',
  'flag_message' => '',
  'unflag_short' => 'unflag',
  'unflag_long' => '',
  'unflag_message' => '',
  'unflag_denied_text' => '',
  'link_type' => 'toggle',
  'roles' => array(
    'flag' => array(
      0 => '2',
      1 => '3',
    ),
    'unflag' => array(
      0 => '2',
      1 => '3',
    ),
  ),
  'weight' => '-7',
  'show_on_form' => 0,
  'access_author' => '',
  'show_on_page' => 1,
  'show_on_teaser' => 1,
  'show_contextual_link' => 0,
  'i18n' => 0,
  'api_version' => 2,
);
return $flags;

Are you using any other modules? Did you select some node types for your flag, or leave it to apply to all?

BarisW’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Hmm, I think I found the issue. I'm using Drupal Commons 3, and they override the export to alter it on another place.

<?php
/**
 * Implements hook_flag_export_alter().
 */
function commons_follow_flag_export_alter(&$flag) {
  // We export $flag->types as an array in code, then dynamically change
  // the values in commons_follow_flag_alter(). Prevent that from being
  // overwritten with the dynamic values.
  if (in_array($flag['name'], array('commons_follow_node', 'email_node'))) {
    $flag['types'] = array();
  }
}
?>

Apologies for the confusion.