summaryrefslogtreecommitdiff
path: root/modules/user/models
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-10-16 07:41:33 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-10-16 08:55:26 -0700
commitbc241e44c2e4d10ac19ccc32a40c90426672d963 (patch)
treeaade0e13346a059c061e2f2f4a767e25a45fe17b /modules/user/models
parent00eacd659f27df9c13246c510057c4f42c8866a2 (diff)
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.
Diffstat (limited to 'modules/user/models')
-rw-r--r--modules/user/models/user.php19
1 files changed, 19 insertions, 0 deletions
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;
+ }
}