Commit bb55784e authored by Zach Copley's avatar Zach Copley

Move getConnectedApps() from Profile to User, where it belongs

parent af4ee1d4
......@@ -97,7 +97,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
$offset = ($this->page - 1) * APPS_PER_PAGE;
$limit = APPS_PER_PAGE + 1;
$connection = $profile->getConnectedApps($offset, $limit);
$connection = $user->getConnectedApps($offset, $limit);
$cnt = 0;
......
......@@ -408,31 +408,6 @@ class Profile extends Memcached_DataObject
return new ArrayWrapper($profiles);
}
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;
}
function subscriptionCount()
{
$c = common_memcache();
......
......@@ -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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment