function _freelinking_exists in Freelinking 6.2
Same name and namespace in other branches
- 5 freelinking.module \_freelinking_exists()
- 6 freelinking.module \_freelinking_exists()
3 calls to _freelinking_exists()
File
- ./
freelinking.module, line 537
Code
function _freelinking_exists($thetitle) {
// helper function for freelinking_page
global $language;
// looks through the db for nodes matching $title. Returns the nid if such a node exists, otherwise, returns 0
$title = urldecode($thetitle);
$query = "SELECT nid FROM {node} WHERE title = '%s'";
if (module_exists('locale')) {
$query .= " AND (language = '{$language->language}' OR language = '')";
}
$noderestrict = variable_get('freelinking_restriction', array(
'none',
));
if (is_array($noderestrict) && !in_array('none', $noderestrict)) {
// need to add the where clause
foreach ($noderestrict as $restrictedtype) {
$clauseparts[] = 'type = "' . $restrictedtype . '"';
}
$restrictions = implode(' OR ', $clauseparts);
$query .= " AND (" . $restrictions . ')';
}
$result = db_query($query, $title);
// FIXME ***
while ($node = db_fetch_object($result)) {
// only one, I hope... what if there's more than one?
$nid = $node->nid;
}
return empty($nid) ? 0 : $nid;
}