summaryrefslogtreecommitdiff
path: root/plugins/Authentication/User_username.php
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-11-13 13:11:28 -0500
committerCraig Andrews <candrews@integralblue.com>2009-11-13 13:11:28 -0500
commit5494eb61465595466b897fdd88efda250c1107e2 (patch)
treec7704867f5fac1c9cbb4cd98edccc3da0b2ba78f /plugins/Authentication/User_username.php
parentb9562cbb18a7b8f3f01bcbc8540933c4dfc10fb9 (diff)
Refactor User_username object creation to reuse code
Diffstat (limited to 'plugins/Authentication/User_username.php')
-rw-r--r--plugins/Authentication/User_username.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/Authentication/User_username.php b/plugins/Authentication/User_username.php
index 79adeb189..f30f60d83 100644
--- a/plugins/Authentication/User_username.php
+++ b/plugins/Authentication/User_username.php
@@ -22,4 +22,25 @@ class User_username extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+
+ /**
+ * Register a user with a username on a given provider
+ * @param User User object
+ * @param string username on the given provider
+ * @param provider_name string name of the provider
+ * @return mixed User_username instance if the registration succeeded, false if it did not
+ */
+ static function register($user, $username, $provider_name)
+ {
+ $user_username = new User_username();
+ $user_username->user_id = $user->id;
+ $user_username->provider_name = $provider_name;
+ $user_username->username = $username;
+ $user_username->created = DB_DataObject_Cast::dateTime();
+ if($user_username->insert()){
+ return $user_username;
+ }else{
+ return false;
+ }
+ }
}