You are here

function flag_plugin_argument_validate_flaggability::get_flag in Flag 6

Same name and namespace in other branches
  1. 6.2 includes/flag_plugin_argument_validate_flaggability.inc \flag_plugin_argument_validate_flaggability::get_flag()
  2. 7.3 includes/views/flag_plugin_argument_validate_flaggability.inc \flag_plugin_argument_validate_flaggability::get_flag()
  3. 7.2 includes/flag_plugin_argument_validate_flaggability.inc \flag_plugin_argument_validate_flaggability::get_flag()
1 call to flag_plugin_argument_validate_flaggability::get_flag()
flag_plugin_argument_validate_flaggability::validate_argument in includes/flag_plugin_argument_validate_flaggability.inc
Tests whether the argument is flaggable, or flagged, or flagged by current user. These are three possible tests, and which of the three to actually carry out is determined by 'flag_test'.

File

includes/flag_plugin_argument_validate_flaggability.inc, line 129
Contains the flaggability validator handler.

Class

flag_plugin_argument_validate_flaggability
Validates whether an argument is a flaggable/flagged object.

Code

function get_flag() {
  $flag_name = $this
    ->_get_option('flag_name', '*relationship*');
  if ($flag_name == '*relationship*') {

    // Pick the first flag mentioned in the relationships.
    foreach ($this->view->relationship as $id => $handler) {

      // Note: we can't do $handler->field, because the relationship handler's init() may overwrite it.
      if (strpos($handler->options['field'], 'flag') !== FALSE && !empty($handler->options['flag'])) {
        $flag = flag_get_flag($handler->options['flag']);
        if ($flag && $flag->content_type == $this->flag_type) {
          return $flag;
        }
      }
    }
  }
  return flag_get_flag($flag_name);
}