function _freelinking_make_link in Freelinking 6.2
Same name and namespace in other branches
- 5 freelinking.module \_freelinking_make_link()
- 6 freelinking.module \_freelinking_make_link()
2 calls to _freelinking_make_link()
File
- ./
freelinking.module, line 561
Code
function _freelinking_make_link($thetitle) {
// helper function for freelinking_page
global $user;
$freelink = array(
'options' => array(),
);
// ensure that 'options' is an array
// Returns a link to a node named $thetitle if found, or a link to new content otherwise.
$nid = _freelinking_exists($thetitle);
if ($nid) {
// the node exists, set the path to go there
$freelink['path'] = 'node/' . $nid;
}
else {
// node doesn't exist, set path to create it
switch (variable_get('freelinking_notfound', 'no access search')) {
case 'create only':
$freelink['path'] = 'node/add/' . variable_get('freelinking_nodetype', 'story');
$freelink['options'] = array(
'query' => 'edit[title]=' . $thetitle,
);
break;
case 'no access search':
if (node_access('create', variable_get('freelinking_nodetype', 'story'))) {
$freelink['path'] = 'node/add/' . variable_get('freelinking_nodetype', 'story');
$freelink['options'] = array(
'query' => 'edit[title]=' . $thetitle,
);
}
else {
$freelink['path'] = 'search/node/' . $thetitle;
}
break;
case 'always search':
$freelink['path'] = 'search/node/' . $thetitle;
break;
}
// endswitch notfound options
}
_freelinking_store($thetitle, $freelink['path'], isset($freelink['args']) ? $freelink['args'] : '');
return $freelink;
}