public function allowed(array $user, $role, Request $request)
{
$table = $this->_getTable($request, $this->config('table'));
//retrieve table id from request
$id = Hash::get($request->{$this->config('tableKeyType')}, $this->config('tableIdParamsKey'));
$userId = Hash::get($user, 'id');
try {
if (!$table->hasField($this->config('ownerForeignKey'))) {
throw new OutOfBoundsException(__d('CakeDC/Users', 'Missing column {0} in table {1} while checking ownership permissions for user {2}', $this->config('ownerForeignKey'), $table->alias(), $userId));
}
} catch (Exception $ex) {
throw new OutOfBoundsException(__d('CakeDC/Users', 'Missing column {0} in table {1} while checking ownership permissions for user {2}', $this->config('ownerForeignKey'), $table->alias(), $userId));
}
$idColumn = $this->config('id');
if (empty($idColumn)) {
$idColumn = $table->primaryKey();
}
$conditions = array_merge([$idColumn => $id, $this->config('ownerForeignKey') => $userId], $this->config('conditions'));
return $table->exists($conditions);
}