diff options
author | Zach Copley <zach@status.net> | 2010-12-12 17:37:42 -0800 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2010-12-12 17:37:42 -0800 |
commit | bb55784e902388f12ae9a0beddf283b48f19531e (patch) | |
tree | 2131a7b029ccc67942add2302d4d0f2997b7af63 /classes/User.php | |
parent | af4ee1d490b86e5d50cfcb62db3b886c9305da8c (diff) |
Move getConnectedApps() from Profile to User, where it belongs
Diffstat (limited to 'classes/User.php')
-rw-r--r-- | classes/User.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php index 8a3190cbf..1b1b971ec 100644 --- a/classes/User.php +++ b/classes/User.php @@ -978,4 +978,34 @@ class User extends Memcached_DataObject { return common_shorten_links($text, $always, $this); } + + /* + * Get a list of OAuth client application that have access to this + * user's account. + */ + function getConnectedApps($offset = 0, $limit = null) + { + $qry = + 'SELECT u.* ' . + 'FROM oauth_application_user u, oauth_application a ' . + 'WHERE u.profile_id = %d ' . + 'AND a.id = u.application_id ' . + 'AND u.access_type > 0 ' . + 'ORDER BY u.created DESC '; + + if ($offset > 0) { + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + } + + $apps = new Oauth_application_user(); + + $cnt = $apps->query(sprintf($qry, $this->id)); + + return $apps; + } + } |