PoetOS / moodle-local_metadata

11 stars 18 forks source link

Field set to Not visible still visible when displayed #11

Open Kemmotar83 opened 6 years ago

Kemmotar83 commented 6 years ago

Hi,

I've created a set of metadata in course context and then I'm using the _local_metadata_displayfields (lib.php) function to display them. I've set a field Not visible but, when I display the fields with above function, it's still visible, even if I view the output as a guest user.

I've checked the code and the _local_metadata_displayfields (lib.php) function calls _$formfield->isvisible() (raw 163) in order to check if the field should be displayed or not and in this function it's never checked if the field is set to "Not visible" (PROFILE_VISIBLE_NONE), that's why it is always displayed. Adding the PROFILE_VISIBLE_NONE case solve the "problem". Am I missing something?

Other than that, in order to use the _local_metadata_displayfields function I've included the lib.php file but, when the code uses the PROFILEVISIBLE* constants, it seems they are not defined so they cannot be correctly evaluated. Do I need to include anything else in order to have these constants defined? Could be better to define local constant, instead of using USER constants?

Thanks for this project. Moodle definitely needs this feature.

Giorgio

mchurchward commented 6 years ago

I guess the question is, what capability is relevant in making course metadata visible/invisible? I don't think it should be the same one used for user profile data. Or should new capabilities be created per context?

Kemmotar83 commented 6 years ago

Yes, maybe a single capability View hidden metadata per context could be the best solution. Then, for each metadata instance, the visibility setting could just be Visible or Hidden.

Thanks, Giorgio