You are here

function flag_lists_get_flag in Flag Lists 7

Same name and namespace in other branches
  1. 6 flag_lists.module \flag_lists_get_flag()
  2. 7.3 flag_lists.module \flag_lists_get_flag()

Get a specific flag.

Using this instead of flag_get_flag() for performance.

9 calls to flag_lists_get_flag()
flag_lists_delete_confirm in ./flag_lists.admin.inc
Delete flag lists page.
flag_lists_delete_confirm_submit in ./flag_lists.admin.inc
flag_lists_form in ./flag_lists.admin.inc
Form to Add or edit a list.
flag_lists_form_submit in ./flag_lists.admin.inc
Save a list.
flag_lists_get_flagged_content in ./flag_lists.module
Get all flagged content in a flag.

... See full list

File

./flag_lists.module, line 1140
The Flag Lists module.

Code

function flag_lists_get_flag($fid) {

  // If we don't have an fid, then we have the flag name.
  if (!is_numeric($fid)) {
    $query = db_select('flag_lists_flags')
      ->condition('name', $fid);
    $query
      ->addField('flag_lists_flags', 'fid');
    $fid = $query
      ->execute()
      ->fetchField();
  }
  $query = db_select('flag_lists_flags', 'fl')
    ->fields('fl')
    ->condition('fl.fid', $fid);
  $query
    ->leftJoin('flag_types', 'ft', 'ft.fid = fl.pfid');
  $query
    ->addField('ft', 'type');
  $result = $query
    ->execute();
  foreach ($result as $row) {
    if (!isset($flag->name)) {
      $flag = flag_flag::factory_by_row($row);
    }
    else {
      $flag->types[] = $row->type;
    }
  }
  return $flag;
}