From bc241e44c2e4d10ac19ccc32a40c90426672d963 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 16 Oct 2009 07:41:33 -0700 Subject: Cleanup merge of user/group helpers into Identity interface. Reduce redundant code in the user module and remove references to the Identity helper from the user module as the user module should be able to access things directly. Simplify the get_user_list api method to just accept an array of ids to return user objects for. --- modules/user/models/user.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'modules/user/models') diff --git a/modules/user/models/user.php b/modules/user/models/user.php index 1993bd05..d99603b2 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -51,6 +51,16 @@ class User_Model extends ORM { module::event("user_deleted", $old); } + /** + * Return a url to the user's avatar image. + * @param integer $size the target size of the image (default 80px) + * @return string a url + */ + public function avatar_url($size=80, $default=null) { + return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s", + md5($this->email), $size, $default ? "&d=" . urlencode($default) : ""); + } + public function save() { if (!$this->loaded) { $created = 1; @@ -63,4 +73,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; + } } -- cgit v1.2.3