New Tools Menu, limit by Profile Fields

Issue #12 resolved
Jeremy Hopkins created an issue

Under BCU > Header there is a custom menu "tools menu". We need a second one adding, "tools menu 2"

We want to be able to limit the visibility of these based on a profile or custom profile field. There would need to be a labels for these settings along the lines of:

"Limit tools menu to profile field values" "Limit tools menu 2 to profile field values"

For this to work we would need two options:

  • profile field
  • value

It maybe you need a third check box to indicate whether the filed is custom or not as custom profile fields have a prefix in front of them that tells moodle to retrieve a custom field as opposed to one from the users table and I am not sure if that will work passed as a string.

The specific rules we want to impose are to only show these tools menu when the custom field of:

"person type" = "staff" "person type" = "student"

By doing this we will be able to have different tools menus display for staff, students or any other group we assign a custom profile field to.

Comments (7)

  1. John Stabinger

    What will go in this second tools menu? i will need some suggested code to check the profile field.

  2. Jeremy Hopkins reporter

    The second tools menu will use an identical format to the existing one. The tools menu renders icons, example input blelow (also in README file):

    Sample code for Tools menu using FA Icons:

    <span class="fa fa-video-camera"></span>Record Screen|http://google.co.uk|Record Screen

    <span class="fa fa-picture-o"></span>ThinkStock|http://google.co.uk|ThinkStock

    <span class="fa fa-clock-o"></span>Exam Clock|http://google.co.uk|Exam Clock

    <span class="fa fa-share-alt"></span>Share a File|http://google.co.uk|Share a File

    <span class="fa fa-globe"></span>Explor|http://google.co.uk|Explor

    <span class="icon-my-cat"></span>MyCat|http://google.co.uk|MyCat

    The method for checking the profile field will be identical to that given in #4 checking against a custom profile field (we will be adding one called "persontype" using something along the lines of:

    • IF (admin field empty) { render menu}; // admin has not applied a rule
    • ELSE IF (admin field == $user->profile_field_persontype} {render menu}, // admin has applied a rule for us to test against
  3. John Stabinger

    So this is separate from the two new menus? I can maybe do it the same way as the other two new menus I think.

    I am assuming, again, there will need to be 3 settings- two fields for profile field and profile field valie and one textarea.

  4. Jeremy Hopkins reporter

    Yes, the two new menus go in the top header area. Tools is an existing feature in the main navigation bar. We need BOTH of these menus to have a user profile restrictoin on them so we need to:

    1. Add rule to existing tools menu
    2. Add new tools menu (copy feature of first)
    3. Add rule to new menu (copy process from first)

    Another video explanation if it helps:

    http://1drv.ms/1UEvXg5

  5. Log in to comment