You are here

function notifications_manage_subscriptions_access in Notifications 7

Same name and namespace in other branches
  1. 6.4 notifications.manage.inc \notifications_manage_subscriptions_access()
  2. 6 notifications.manage.inc \notifications_manage_subscriptions_access()
  3. 6.2 notifications.manage.inc \notifications_manage_subscriptions_access()
  4. 6.3 notifications.manage.inc \notifications_manage_subscriptions_access()

Check access for current user to manage multiple subscriptions

Parameters

$sids: Array of subscription ids

3 calls to notifications_manage_subscriptions_access()
notifications_manage_subscriptions_form_validate in ./notifications.manage.inc
Validate notifications_admin_subscriptions form submissions.
notifications_multiple_delete_confirm in ./notifications.pages.inc
Form for multiple delete. When account passed check that all subscriptions belong to the user account
notifications_multiple_delete_confirm_validate in ./notifications.pages.inc
Validate permissions to delete all the subscriptions

File

./notifications.manage.inc, line 14
Common functions for bulk management of subscriptions

Code

function notifications_manage_subscriptions_access($sids) {
  if (user_access('administer notifications') || user_access('manage all subscriptions')) {
    return TRUE;
  }
  else {
    $count = db_query("SELECT COUNT(*) FROM {notifications_subscription} WHERE uid = :uid AND sid IN (:sid)", array(
      ':uid' => $GLOBALS['user']->uid,
      ':sid' => $sids,
    ))
      ->fetchField();
    return $count == count($sids);
  }
}