diff options
author | Zach Copley <zach@status.net> | 2010-02-02 08:48:52 +0000 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2010-02-02 08:48:52 +0000 |
commit | 2be00ce64221197f3c8ad1458eba2488c8836e5c (patch) | |
tree | b3fd0ee62c631f53b2c8670ec1f109283b2d6b34 /lib | |
parent | 952b5806987e12a34e6fd75509b5d78815c1aa2d (diff) | |
parent | 5e90f744a6fb58c43f8f5332ef868ba38e82b3d1 (diff) |
Merge branch 'oauth-continued' into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api.php | 19 | ||||
-rw-r--r-- | lib/apioauthstore.php | 27 | ||||
-rw-r--r-- | lib/noticelist.php | 20 | ||||
-rw-r--r-- | lib/router.php | 4 |
4 files changed, 67 insertions, 3 deletions
diff --git a/lib/api.php b/lib/api.php index 987f2cc1b..7d94eaee4 100644 --- a/lib/api.php +++ b/lib/api.php @@ -1250,10 +1250,27 @@ class ApiAction extends Action case 'api': break; default: + + $name = null; + $url = null; + $ns = Notice_source::staticGet($source); + if ($ns) { - $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>'; + $name = $ns->name; + $url = $ns->url; + } else { + $app = Oauth_application::staticGet('name', $source); + if ($app) { + $name = $app->name; + $url = $app->source_url; + } + } + + if (!empty($name) && !empty($url)) { + $source_name = '<a href="' . $url . '">' . $name . '</a>'; } + break; } return $source_name; diff --git a/lib/apioauthstore.php b/lib/apioauthstore.php index 32110d057..1bb11cbca 100644 --- a/lib/apioauthstore.php +++ b/lib/apioauthstore.php @@ -159,5 +159,32 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore } } + /** + * Revoke specified access token + * + * Revokes the token specified by $token_key. + * Throws exceptions in case of error. + * + * @param string $token_key the token to be revoked + * @param int $type type of token (0 = req, 1 = access) + * + * @access public + * + * @return void + */ + + public function revoke_token($token_key, $type = 0) { + $rt = new Token(); + $rt->tok = $token_key; + $rt->type = $type; + $rt->state = 0; + if (!$rt->find(true)) { + throw new Exception('Tried to revoke unknown token'); + } + if (!$rt->delete()) { + throw new Exception('Failed to delete revoked token'); + } + } + } diff --git a/lib/noticelist.php b/lib/noticelist.php index 85c169716..a4a0f2651 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -486,12 +486,28 @@ class NoticeListItem extends Widget $this->out->element('span', 'device', $source_name); break; default: + + $name = null; + $url = null; + $ns = Notice_source::staticGet($this->notice->source); + if ($ns) { + $name = $ns->name; + $url = $ns->url; + } else { + $app = Oauth_application::staticGet('name', $this->notice->source); + if ($app) { + $name = $app->name; + $url = $app->source_url; + } + } + + if (!empty($name) && !empty($url)) { $this->out->elementStart('span', 'device'); - $this->out->element('a', array('href' => $ns->url, + $this->out->element('a', array('href' => $url, 'rel' => 'external'), - $ns->name); + $name); $this->out->elementEnd('span'); } else { $this->out->element('span', 'device', $source_name); diff --git a/lib/router.php b/lib/router.php index b046b240c..987d0152e 100644 --- a/lib/router.php +++ b/lib/router.php @@ -152,6 +152,10 @@ class Router array('action' => 'editapplication'), array('id' => '[0-9]+') ); + $m->connect('settings/oauthapps/delete/:id', + array('action' => 'deleteapplication'), + array('id' => '[0-9]+') + ); // search |