You are here

function shurly_delete_access in ShURLy 6

Same name and namespace in other branches
  1. 7 shurly.module \shurly_delete_access()

Access callback for deleting (deactivating) a URL

1 string reference to 'shurly_delete_access'
shurly_menu in ./shurly.module
Implementation of hook_menu()

File

./shurly.module, line 137
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_fetch_object(db_query('SELECT uid, source, destination FROM {shurly} WHERE rid = %d', $rid));

    // 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;
}