You are here

public function Notifications_Subscription_List::check_access in Notifications 7

Check access for current user to manage multiple subscriptions

File

./notifications.list.inc, line 201
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription_List
List of subscriptions or subscription types

Code

public function check_access($account = NULL) {
  $account = $account ? $account : $GLOBALS['user'];
  if (user_access('administer notifications', $account) || user_access('manage all subscriptions', $account)) {
    return TRUE;
  }
  else {

    // Check all subscriptions belong to the user
    foreach ($this
      ->get_subscriptions() as $subscription) {
      if (isset($subscription->uid) && $subscription->uid != $account->uid) {
        return FALSE;
      }
    }
    return TRUE;
  }
}