$prefix . ts('view my invoices'),
ts('Allow users to view/ download their own invoices'),
),
+ 'edit api keys' => array(
+ $prefix . ts('edit api keys'),
+ ts('Edit API keys'),
+ ),
+ 'edit own api keys' => array(
+ $prefix . ts('edit own api keys'),
+ ts('Edit user\'s own API keys'),
+ ),
);
return $permissions;
return $values;
}
+ if (array_key_exists('api_key', $params) && !empty($params['check_permissions'])) {
+ if (CRM_Core_Permission::check('edit api keys') || CRM_Core_Permission::check('administer CiviCRM')) {
+ // OK
+ }
+ elseif ($contactID && CRM_Core_Permission::check('edit own api keys') && CRM_Core_Session::singleton()->get('userID') == $contactID) {
+ // OK
+ }
+ else {
+ throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify api key');
+ }
+ }
+
if (!$contactID) {
// If we get here, we're ready to create a new contact
if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {