After posting the same question on drupal.stackexchange, I was suggested a solution using some PHP code in Views (contextual filter). It's the best solution I've found yet, so unless someone can propose a better solution, I'll stick with this one.
Here is the solution: https://drupal.stackexchange.com/questions/38205/alter-field-settings-using-hook/38922#38922
And here is the gist of it:
In the View, add a contextual filter on Author: Uid
, and use the following settings:
WHEN THE FILTER VALUE IS NOT AVAILABLE:
- Provide default value
- Type: PHP Code
Use the following code:
global $user;
if (in_array('administrator', $user->roles))
{return -1;}
else
{return $user->uid;}
WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED
- Specify validation criteria
- Validator: PHP Code
Use the following code:
if ($argument == -1)
{return FALSE;}
else
{return TRUE;}
- Action to take if filter value does not validate: Display all results for the specified field (this is what will give admins access to all results)
And that's it!
Notes:
Compared to my initial settings, the relationship (Content: Author) isn't needed anymore; neither is the "Author" filter (which was brought in by the relationship anyway).
For Drupal 6, the condition in the first PHP snippet should rather be if (in_array('super user', array_values($user->roles)))
You can allow other roles as well, simply by editing the condition above. For instance:
if (
in_array('administrator', $user->roles) ||
in_array('editor', $user->roles)
)