commit 81c1f2571185c82964c30734956169b899a688d0 Author: Bart Feenstra Date: Wed Jan 22 15:21:02 2014 +0100 foo diff --git a/payment/includes/PaymentOwnOverviewViewsHandlerAccess.inc b/payment/includes/PaymentOwnOverviewViewsHandlerAccess.inc new file mode 100644 index 0000000..60cd56f --- /dev/null +++ b/payment/includes/PaymentOwnOverviewViewsHandlerAccess.inc @@ -0,0 +1,49 @@ +View any payment permission, or to people with the View own payments permission who access their own payments.'); + } + + /** + * {@inheritdoc} + */ + function access($account) { + return _payment_own_overview_views_handler_access($account); + } + + /** + * {@inheritdoc} + */ + function get_access_callback() { + return array('_payment_own_overview_views_handler_access', array()); + } +} + +/** + * Implements menu access callback. + * + * @see PaymentOwnOverviewViewsHandlerAccess::get_access_callback() + * + * @param stdClass|null $account + * The account for which to check access. Defaults to the currently logged-in + * user. + * + * @return bool + */ +function _payment_own_overview_views_handler_access($account = NULL) { + global $user; + + if (!$account) { + $account = $user; + } + + return user_access('payment.payment.view.any') || user_access('payment.payment.view.own') && $account->uid == arg(1); +} diff --git a/payment/views/payment.views.inc b/payment/views/payment.views.inc index 9a28ad8..6c1f085 100644 --- a/payment/views/payment.views.inc +++ b/payment/views/payment.views.inc @@ -388,3 +388,16 @@ function payment_views_data_alter(&$data) { ), ); } + +/** + * Implements hook_views_plugins(). + */ +function payment_views_plugins() { + $plugins = array(); + $plugins['access']['payment_own_overview_views_handler_access'] = array( + 'title' => t('People with the View any payment permission and people who own the payments'), + 'handler' => 'PaymentOwnOverviewViewsHandlerAccess', + ); + + return $plugins; +}