function shurly_edit_access in ShURLy 7
Access callback for editing a URL
1 string reference to 'shurly_edit_access'
- shurly_menu in ./
shurly.module - Implements hook_menu().
File
- ./
shurly.module, line 235 - description http://www.youtube.com/watch?v=Qo7qoonzTCE
Code
function shurly_edit_access($rid) {
if (is_numeric($rid)) {
global $user;
if (!$user->uid) {
// anonymous users can't edit URLs
return FALSE;
}
// see if there's a row
$row = db_query('SELECT uid, source, destination FROM {shurly} WHERE rid = :rid', array(
'rid' => $rid,
))
->fetchObject();
// if there's a row, and either the user is an admin, or they've got permission to create and they own this URL, then let them access
if ($row && (user_access('Administer short URLs') || user_access('Edit own URLs') && $row->uid == $user->uid)) {
return TRUE;
}
}
return FALSE;
}