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.

This commit is contained in:
Tim Almdal
2009-10-16 08:55:26 -07:00
parent 00eacd659f
commit bc241e44c2
11 changed files with 113 additions and 211 deletions
+19
View File
@@ -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;
}
}