You are here

function flag_get_default_flags in Flag 6.2

Same name and namespace in other branches
  1. 5 flag.module \flag_get_default_flags()
  2. 6 flag.module \flag_get_default_flags()
  3. 7.3 flag.module \flag_get_default_flags()
  4. 7.2 flag.module \flag_get_default_flags()

Retrieve a list of flags defined by modules.

Parameters

$include_disabled: Unless specified, only enabled flags will be returned.

Return value

An array of flag prototypes, not usable for flagging. Use flag_get_flags() if needing to perform a flagging with any enabled flag.

5 calls to flag_get_default_flags()
flag_admin_page in includes/flag.admin.inc
Flag administration page. Display a list of existing flags.
flag_features_export_options in includes/flag.features.inc
Implements hook_features_export_options().
flag_flag::find_default_flag in ./flag.inc
Finds the "default flag" corresponding to this flag.
flag_get_flags in ./flag.module
List all flags available.
flag_load in ./flag.module
Menu loader for '%flag' arguments.

File

./flag.module, line 1419
The Flag module.

Code

function flag_get_default_flags($include_disabled = FALSE) {
  $default_flags = array();
  $flag_status = variable_get('flag_default_flag_status', array());
  foreach (module_implements('flag_default_flags') as $module) {
    $function = $module . '_flag_default_flags';
    foreach ($function() as $flag_name => $flag_info) {

      // Backward compatibility: old exported default flags have their names
      // in $flag_info instead, so we use the += operator to not overwrite it.
      $flag_info += array(
        'name' => $flag_name,
        'module' => $module,
      );
      $flag = flag_flag::factory_by_array($flag_info);

      // Disable flags that are not at the current API version.
      if (!$flag
        ->is_compatible()) {
        $flag->status = FALSE;
      }

      // Add flags that have been enabled.
      if (!isset($flag_status[$flag->name]) && (!isset($flag->status) || $flag->status) || !empty($flag_status[$flag->name])) {
        $flag->status = TRUE;
        $default_flags[$flag->name] = $flag;
      }
      elseif ($include_disabled) {
        $flag->status = FALSE;
        $default_flags[$flag->name] = $flag;
      }
    }
  }
  return $default_flags;
}