function shurly_delete_access in ShURLy 7
Same name and namespace in other branches
- 6 shurly.module \shurly_delete_access()
Access callback for deleting (deactivating) a URL
1 string reference to 'shurly_delete_access'
- shurly_menu in ./
shurly.module - Implements hook_menu().
File
- ./
shurly.module, line 374 - description http://www.youtube.com/watch?v=Qo7qoonzTCE
Code
function shurly_delete_access($rid) {
if (is_numeric($rid)) {
global $user;
if (!$user->uid) {
// anonymous users can't delete 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('Delete own URLs') && $row->uid == $user->uid)) {
return TRUE;
}
}
return FALSE;
}