summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-19 16:50:35 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-19 16:50:35 -0700
commit51dca582cd2cda9416ec0172f8ed9a19ba828fec (patch)
tree66f988ab4dd00d25a32452cdd2aa32835cb5dcd9
parent2572e5810f9d66fa39fa97838818a25bf4f393f3 (diff)
More thorough fix for #421. Create User_Model::display_name() which
uses the full name if there is one, or falls back to the name if that's all we have.
-rw-r--r--modules/info/views/info_block.html.php4
-rw-r--r--modules/user/models/user.php9
-rw-r--r--modules/user/views/login.html.php2
3 files changed, 12 insertions, 3 deletions
diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php
index 9f544376..f86ae39d 100644
--- a/modules/info/views/info_block.html.php
+++ b/modules/info/views/info_block.html.php
@@ -26,9 +26,9 @@
<li>
<strong class="caption"><?= t("Owner:") ?></strong>
<? if ($item->owner->url): ?>
- <a href="<?= $item->owner->url ?>"><?= p::clean($item->owner->full_name) ?></a>
+ <a href="<?= $item->owner->url ?>"><?= p::clean($item->owner->display_name()) ?></a>
<? else: ?>
- <?= p::clean($item->owner->name) ?>
+ <?= p::clean($item->owner->display_name()) ?>
<? endif ?>
</li>
<? endif ?>
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index 0234f186..def65a6f 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -72,4 +72,13 @@ class User_Model extends ORM {
}
return $this;
}
+
+ /**
+ * Return the best version of the user's name. Either their specified full name, or fall back
+ * to the user name.
+ * @return string
+ */
+ public function display_name() {
+ return empty($this->full_name) ? $this->name : $this->full_name;
+ }
} \ No newline at end of file
diff --git a/modules/user/views/login.html.php b/modules/user/views/login.html.php
index 7617d131..4c1a5b3c 100644
--- a/modules/user/views/login.html.php
+++ b/modules/user/views/login.html.php
@@ -12,7 +12,7 @@
'<a href="' . url::site("form/edit/users/{$user->id}") .
'" title="' . t("Edit Your Profile") .
'" id="gUserProfileLink" class="gDialogLink">' .
- p::clean(empty($user->full_name) ? $user->name : $user->full_name) . '</a>')) ?>
+ p::clean($user->display_name()) . '</a>')) ?>
</li>
<li>
<a href="<?= url::site("logout?csrf=$csrf&continue=" . url::current(true)) ?>"