Skip to content

Commit

Permalink
Tweak PersonsName->getShort() and getShortFormal()
Browse files Browse the repository at this point in the history
The functions PersonsName->getShort() and getShortFormal() had also problems with users that don't have first AND last name
  • Loading branch information
gerundt committed Jan 20, 2021
1 parent ad91e66 commit fa64ad4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions include/class.user.php
Expand Up @@ -847,12 +847,24 @@ function getMiddle() {
return $this->parts['middle'];
}

function getFirstInitial() {
if ($this->parts['first'])
return mb_substr($this->parts['first'],0,1).'.';
return '';
}

function getMiddleInitial() {
if ($this->parts['middle'])
return mb_substr($this->parts['middle'],0,1).'.';
return '';
}

function getLastInitial() {
if ($this->parts['last'])
return mb_substr($this->parts['last'],0,1).'.';
return '';
}

function getFormal() {
return trim($this->parts['salutation'].' '.$this->parts['last']);
}
Expand Down Expand Up @@ -890,11 +902,11 @@ function getLastFirst() {
}

function getShort() {
return $this->parts['first'].' '.mb_substr($this->parts['last'],0,1).'.';
return $this->parts['first'].' '.$this->getLastInitial();
}

function getShortFormal() {
return mb_substr($this->parts['first'],0,1).'. '.$this->parts['last'];
return $this->getFirstInitial().' '.$this->parts['last'];
}

function getOriginal() {
Expand Down

0 comments on commit fa64ad4

Please sign in to comment.