function ctools_string_equal_ctools_access_check

Check for access.

1 string reference to 'ctools_string_equal_ctools_access_check'
string_equal.inc in plugins/access/string_equal.inc

File

plugins/access/string_equal.inc, line 52

Code

function ctools_string_equal_ctools_access_check($conf, $context) {
    if (empty($context) || empty($context->data)) {
        $string = '';
    }
    else {
        $string = $context->data;
    }
    $value = $conf['value'];
    if (empty($conf['case'])) {
        $string = drupal_strtolower($string);
        $value = drupal_strtolower($value);
    }
    switch ($conf['operator']) {
        case '=':
            return $string === $value;
        case '!=':
            return $string !== $value;
        case 'regex':
            return preg_match($value, $string);
        case '!regex':
            return !preg_match($value, $string);
    }
}