Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-51427

Incorrect usage of language strings for user fields 'phone1' and 'phone2'

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Edit admin user and add both phones
      2. Make sure they are displayed as "Phone" and "Mobile phone" in:
        • user profile
        • admin setting showuseridentity
        • Upload user tool
        • "Logged in user" block (both in settings and in the block itself)
        • In the available fields dropdown when you add URL resource
        • any authentication plugin settings page
      3. Add both fields to the "showuseridentity" and make sure they appear correctly on "Participants" page
      Show
      Edit admin user and add both phones Make sure they are displayed as "Phone" and "Mobile phone" in: user profile admin setting showuseridentity Upload user tool "Logged in user" block (both in settings and in the block itself) In the available fields dropdown when you add URL resource any authentication plugin settings page Add both fields to the "showuseridentity" and make sure they appear correctly on "Participants" page
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-51427-master

      Description

      I need to use the 'phone1' field in auth/LDAP for something other than a phone number - Manager's name in this case. However, searching through the 'en' language pack reveals that there is no specific language string for 'phone1'. In fact, 'phone1' uses the language string for 'phone', with the '1' tacked on at the end. This is done in print_auth_lock_options() (in admin/auth_config.php).

      The problem with that approach is that changing the language string for 'phone' to 'Manager' results in 'phone1' and 'phone2' fields being labelled 'Manager 1' and Manager 2' respectively. Worse, 'phone' field is now labelled 'Manager' everywhere!

      What I want is to be able to change the language string for 'phone1' without affecting 'phone' or 'phone2'.

      This is achievable by getting rid of two lines in print_auth_lock_options(), and adding a new language string for 'phone1' to lang/moodle.php:

      --- HEAD
      +++ Modified In Working Tree
      @@ -146,8 +146,8 @@
                   // If custom field then pick name from database.
                   $fieldshortname = str_replace('profile_field_', '', $fieldname);
                   $fieldname = $customfieldname[$fieldshortname]->name;
      -        } elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
      -            $fieldname =  get_string($matches[1]) . ' ' . $matches[2];
      +//        } elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
      +//            $fieldname =  get_string($matches[1]) . ' ' . $matches[2];
               } elseif ($fieldname == 'url') {
                   $fieldname = get_string('webpage');
               } else {
      
      

      and

      --- HEAD
      +++ Modified In Working Tree
      @@ -1427,6 +1427,7 @@
       $string['personal'] = 'Personal';
       $string['personalprofile'] = 'Personal profile';
       $string['phone'] = 'Phone';
      +$string['phone1'] = 'Phone 1';
       $string['phone2'] = 'Mobile phone';
       $string['phpinfo'] = 'PHP info';
       $string['pictureof'] = 'Picture of {$a}';
      
      

      I found the issue on 2.9.1 (Build: 20150706) but as far as I can tell has been an issue since 1.9.x (e.g. MDL-13151)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Nov/15