function redirect_fetch_rids_by_path in Redirect 7.2
Same name and namespace in other branches
- 7 redirect.module \redirect_fetch_rids_by_path()
Fetches multiple URL redirect IDs from the database by {redirect}.source.
Parameters
$source: The source of the URL redirect.
$language: Language of the source URL.
$enabled_only: Boolean that indicates whether to only load enabled redirects.
Return value
array An indexed array of IDs, or an empty array if there is no result set.
2 calls to redirect_fetch_rids_by_path()
- redirect_disable_by_path in ./
redirect.module - Disable any redirects associated with a path.
- redirect_load_by_source in ./
redirect.module - Load multiple URL redirects from the database by {redirect}.source.
File
- ./
redirect.module, line 580
Code
function redirect_fetch_rids_by_path($source, $language, $enabled_only = FALSE) {
static $status_field_exists = NULL;
if (!isset($status_field_exists)) {
// Prevent errors if redirect_update_7101() has not yet been run.
$status_field_exists = db_field_exists('redirect', 'status');
}
// Run a case-insensitive query for matching RIDs first.
$rid_query = db_select('redirect');
$rid_query
->addField('redirect', 'rid');
if ($enabled_only && $status_field_exists) {
$rid_query
->condition('status', 1);
}
if ($source != variable_get('site_frontpage', 'node')) {
$rid_query
->condition('source', db_like($source), 'LIKE');
}
else {
$source_condition = db_or();
$source_condition
->condition('source', db_like($source), 'LIKE');
$source_condition
->condition('source', '');
$rid_query
->condition($source_condition);
}
$rid_query
->condition('language', array(
$language,
LANGUAGE_NONE,
));
$rid_query
->addTag('redirect_fetch');
$rids = $rid_query
->execute()
->fetchCol();
return $rids;
}