buildClause() public static method

Builds an LDAP search filter fragment.
public static buildClause ( string $lhs, string $op, string $rhs, array $params = [] ) : string
$lhs string The attribute to test.
$op string The operator.
$rhs string The comparison value.
$params array Any additional parameters for the operator.
return string The LDAP search fragment.
Exemplo n.º 1
0
 /**
  * Build a piece of a search query.
  *
  * @param array  $criteria  The array of criteria.
  *
  * @return string  An LDAP query fragment.
  */
 protected function _buildSearchQuery(array $criteria)
 {
     $clause = '';
     foreach ($criteria as $key => $vals) {
         if (!empty($vals['OR']) || $key === 'OR') {
             $clause .= '(|' . $this->_buildSearchQuery($vals) . ')';
         } elseif (!empty($vals['AND'])) {
             $clause .= '(&' . $this->_buildSearchQuery($vals) . ')';
         } else {
             if (isset($vals['field'])) {
                 $rhs = Horde_String::convertCharset($vals['test'], 'UTF-8', $this->_params['charset']);
                 $clause .= Horde_Ldap::buildClause($vals['field'], $vals['op'], $rhs, array('begin' => !empty($vals['begin'])));
             } else {
                 foreach ($vals as $test) {
                     if (!empty($test['OR'])) {
                         $clause .= '(|' . $this->_buildSearchQuery($test) . ')';
                     } elseif (!empty($test['AND'])) {
                         $clause .= '(&' . $this->_buildSearchQuery($test) . ')';
                     } else {
                         $rhs = Horde_String::convertCharset($test['test'], 'UTF-8', $this->_params['charset']);
                         $clause .= Horde_Ldap::buildClause($test['field'], $test['op'], $rhs, array('begin' => !empty($vals['begin'])));
                     }
                 }
             }
         }
     }
     return $clause;
 }