function ctools_string_length_ctools_access_check

Check for access.

1 string reference to 'ctools_string_length_ctools_access_check'
string_length.inc in plugins/access/string_length.inc

File

plugins/access/string_length.inc, line 49

Code

function ctools_string_length_ctools_access_check($conf, $context) {
    if (empty($context) || empty($context->data)) {
        $length = 0;
    }
    else {
        $length = drupal_strlen($context->data);
    }
    switch ($conf['operator']) {
        case '<':
            return $length < $conf['length'];
        case '<=':
            return $length <= $conf['length'];
        case '=':
            return $length == $conf['length'];
        case '!=':
            return $length != $conf['length'];
        case '>':
            return $length > $conf['length'];
        case '>=':
            return $length >= $conf['length'];
    }
    // Invalid Operator sent, return FALSE.
    return FALSE;
}