Moodle
  1. Moodle
  2. MDL-20199

Database: ##firstname## and ##lastname## tags not working in templates

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not a bug
    • Affects Version/s: 1.9.5
    • Fix Version/s: None
    • Labels:
      None
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      2467

      Description

      Per http://moodle.org/mod/forum/discuss.php?d=131591#p575882 I am creating this issue to document that while the options are listed for using the ##firstname## and ##lastname## tags they do not actually work. I am attaching at first a quick fix that will make it functional; however, it does not respect CFG->forcefirstname or CFG->forcelastname. To do so, I would like to propose modifying the fullname function such that the override parameter indicates the type of override. 0 or false would continue to mean that there is no override; however, I would advocate for changing 1 to 'fullname' and then use 'firstname' and 'lastname' as optional parameters. Thus the options would be:

      fullname($user, 'fullname')
      fullname($user, 'lastname')
      fullname($user, 'firstname')

      I think this will make the fullname function more flexible and avoid having to use the get_field ('user', 'lastname', 'id',$record->userid). That way we can enforce the CFG->forcefirstname and CFG->forcelastname options and not accidentally disclose user names. So I would advocate for not applying this first patch which is really only for folks wanting a quick and dirty fix. I'll work on something better shortly but will need to check all the places where fullname is used to make sure any fullname($user,1) calls get switched to 'fullname'. Of course I am open to other suggestions or ideas as well.

      Peace - Anthony

      1. database_firstname_proposed.patch
        4 kB
        Anthony Borrow
      2. database_firstname.patch
        1 kB
        Anthony Borrow
      3. database_firstname.patch
        1 kB
        Anthony Borrow

        Issue Links

          Activity

          Hide
          Anthony Borrow added a comment -

          I am updating the patch since the get_field is not necessary. I was thinking that fullname just received the user id and was actually looking up the record but now I see that it must have firstname and lastname already. I still think that we may want to revise the fullname function so as not to disclose the user's name when the $CFG->force(first/last)name option is being used. Peace - Anthony

          Show
          Anthony Borrow added a comment - I am updating the patch since the get_field is not necessary. I was thinking that fullname just received the user id and was actually looking up the record but now I see that it must have firstname and lastname already. I still think that we may want to revise the fullname function so as not to disclose the user's name when the $CFG->force(first/last)name option is being used. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          Thinking about this further, I am not a fan of the fullname($user,'firstname') as the result returned is not a fullname so why call the function fullname. Perhaps we should create firstname and lastname functions that will function similarly. If we were to do that, my question is might the function be more useful if it checked to if a firstname and lastname value were identified and if not then lookup those using the id number? Peace - Anthony

          Show
          Anthony Borrow added a comment - Thinking about this further, I am not a fan of the fullname($user,'firstname') as the result returned is not a fullname so why call the function fullname. Perhaps we should create firstname and lastname functions that will function similarly. If we were to do that, my question is might the function be more useful if it checked to if a firstname and lastname value were identified and if not then lookup those using the id number? Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          Here is a proposed patch that creates firstname and lastname functions in /lib/moodlelib.php. Using these functions will help to ensure that the privacy of user names is maintained on sites using $CFG->forrce

          {first/last}

          name. It may be that we want to put the firstname and lastname functions in /mod/data/lib.php as I am not sure if they may or may not be useful in other settings. I will leave this to the discretion of the lucky person assigned this issue. Peace - Anthony

          Show
          Anthony Borrow added a comment - Here is a proposed patch that creates firstname and lastname functions in /lib/moodlelib.php. Using these functions will help to ensure that the privacy of user names is maintained on sites using $CFG->forrce {first/last} name. It may be that we want to put the firstname and lastname functions in /mod/data/lib.php as I am not sure if they may or may not be useful in other settings. I will leave this to the discretion of the lucky person assigned this issue. Peace - Anthony
          Hide
          Michael de Raadt added a comment -

          Thanks for reporting this issue.

          We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

          If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

          Michael d;

          lqjjLKA0p6

          Show
          Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
          Hide
          Anthony Borrow added a comment -

          As best I can tell, the lastname and firstname tags were never really part of the available tags. I had seen them mentioned (erroneously I believe) in Moodle Docs. I'm going to remove them from the Docs and close this as not a bug. Peace - Anthony

          Show
          Anthony Borrow added a comment - As best I can tell, the lastname and firstname tags were never really part of the available tags. I had seen them mentioned (erroneously I believe) in Moodle Docs. I'm going to remove them from the Docs and close this as not a bug. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          Helen - I've removed references to ##firstname## and ##lastname## from available tags section in http://docs.moodle.org/22/en/Database_templates#Tag_usage (and also for 2.1, 2.0 and 1.9). As far as I can tell it was never there in the code (unless I'm mistaken and overlooking something). Peace - Anthony

          Show
          Anthony Borrow added a comment - Helen - I've removed references to ##firstname## and ##lastname## from available tags section in http://docs.moodle.org/22/en/Database_templates#Tag_usage (and also for 2.1, 2.0 and 1.9). As far as I can tell it was never there in the code (unless I'm mistaken and overlooking something). Peace - Anthony

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: