You are here

function _path_redirect_build_conditions in Path redirect 6

3 calls to _path_redirect_build_conditions()
path_redirect_delete_multiple in ./path_redirect.module
Delete multiple redirects.
path_redirect_list_redirects in ./path_redirect.admin.inc
@file Administrative page callbacks for the path_redirect module.
path_redirect_load_multiple in ./path_redirect.module

File

./path_redirect.module, line 471

Code

function _path_redirect_build_conditions(&$query, $rids, $conditions) {
  static $schema;
  if (!isset($schema)) {
    $schema = !defined('MAINTENANCE_MODE') ? drupal_get_schema('path_redirect') : drupal_get_schema_unprocessed('path_redirect', 'path_redirect');
  }
  $query += array(
    'conditions' => array(),
    'args' => array(),
  );
  if ($rids) {
    $conditions += array(
      'rid' => array(),
    );
    $conditions['rid'] = array_merge($rids, (array) $conditions['rid']);
  }
  if ($conditions) {
    foreach ($conditions as $field => $value) {
      if (!is_string($field) || !isset($schema['fields'][$field])) {
        continue;
      }

      //if ($field == 'langauge' && !is_array($value)) {

      //  $value = array($value, '');

      //}
      $type = $schema['fields'][$field]['type'];
      if (is_array($value)) {
        $conditions[$field] = "{$field} IN (" . db_placeholders($value, $type) . ')';
        $query['args'] = array_merge($query['args'], $value);
      }
      else {
        $conditions[$field] = "{$field} = " . db_type_placeholder($type);
        $query['args'][] = $value;
      }
    }
  }
  $query['conditions'] = array_merge($query['conditions'], $conditions);
  return $query;
}