|| $name == self::DN_SHORT || $name == self::DN_SORT;
}
+ /** Returns the closest "accounts only" name type for $name
+ */
+ public static function getAccountEquivalentName($name)
+ {
+ switch ($name)
+ {
+ case self::DN_DIRECTORY:
+ case self::DN_SORT:
+ return 'directory_name';
+ case self::DN_FULL:
+ case self::DN_PUBLIC:
+ return 'full_name';
+ case self::DN_PRIVATE:
+ case self::DN_SHORT:
+ case self::DN_YOURSELF:
+ default:
+ return 'display_name';
+ }
+ }
+
public static function getNameTypeId($type, $for_sql = false)
{
if (!S::has('name_types')) {
{
if (Profile::isDisplayName($this->type)) {
$sub = $uf->addDisplayFilter();
- return 'pd' . $sub . '.' . $this->type;
+ $token = 'pd' . $sub . '.' . $this->type;
+ if ($uf->accountsRequired()) {
+ $account_token = Profile::getAccountEquivalentName($this->type);
+ return 'IFNULL(' . $token . ', a.' . $account_token . ')';
+ } else {
+ return $token;
+ }
} else {
$sub = $uf->addNameFilter($this->type, $this->variant);
if ($this->particle) {
$this->with_accounts = true;
}
+ public function accountsRequired()
+ {
+ return $this->with_accounts;
+ }
+
public function requireProfiles()
{
$this->with_profiles = true;
}
+ public function profilesRequired()
+ {
+ return $this->with_profiles;
+ }
+
protected function accountJoins()
{
$joins = array();