123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- require_once INSTALLDIR . '/lib/widget.php';
- define('APPS_PER_PAGE', 20);
- class ApplicationList extends Widget
- {
-
- var $application = null;
-
- var $owner = null;
-
- var $action = null;
- function __construct($application, $owner=null, $action=null)
- {
- parent::__construct($action);
- $this->application = $application;
- $this->owner = $owner;
- $this->action = $action;
- }
- function show()
- {
- $this->out->elementStart('ul', 'applications');
- $cnt = 0;
- while ($this->application->fetch()) {
- $cnt++;
- if($cnt > APPS_PER_PAGE) {
- break;
- }
- $this->showapplication();
- }
- $this->out->elementEnd('ul');
- return $cnt;
- }
- function showApplication()
- {
- $user = common_current_user();
- $this->out->elementStart('li', array('class' => 'application h-entry',
- 'id' => 'oauthclient-' . $this->application->id));
- $this->out->elementStart('a', array('href' => common_local_url('showapplication',
- array('id' => $this->application->id)),
- 'class' => 'h-card'));
- if (!empty($this->application->icon)) {
- $this->out->element('img', array('src' => $this->application->icon,
- 'class' => 'avatar u-photo'));
- }
- $this->out->text($this->application->name);
- $this->out->elementEnd('a');
- $this->out->raw(' by ');
- $this->out->element('a', array('href' => $this->application->homepage,
- 'class' => 'u-url'),
- $this->application->organization);
- $this->out->element('p', 'note', $this->application->description);
- $this->out->elementEnd('li');
- }
-
- function showOwnerControls()
- {
- return;
- }
- }
- class ConnectedAppsList extends Widget
- {
-
- var $connection = null;
-
- var $owner = null;
-
- var $action = null;
- function __construct($connection, $owner=null, $action=null)
- {
- parent::__construct($action);
- common_debug("ConnectedAppsList constructor");
- $this->connection = $connection;
- $this->owner = $owner;
- $this->action = $action;
- }
-
- function showOwnerControls()
- {
- return;
- }
- function show()
- {
- $this->out->elementStart('ul', 'applications');
- $cnt = 0;
- while ($this->connection->fetch()) {
- $cnt++;
- if($cnt > APPS_PER_PAGE) {
- break;
- }
- $this->showConnection();
- }
- $this->out->elementEnd('ul');
- return $cnt;
- }
- function showConnection()
- {
- $app = Oauth_application::getKV('id', $this->connection->application_id);
- $this->out->elementStart('li', array('class' => 'application h-entry',
- 'id' => 'oauthclient-' . $app->id));
- $this->out->elementStart('a', array('href' => $app->source_url,
- 'class' => 'h-card p-name'));
- if (!empty($app->icon)) {
- $this->out->element('img', array('src' => $app->icon,
- 'class' => 'avatar u-photo'));
- }
- if ($app->name != 'anonymous') {
- $this->out->text($app->name);
- } else {
-
- $this->out->element('span', 'p-name', _('Unknown application'));
- }
- $this->out->elementEnd('a');
- if ($app->name != 'anonymous') {
-
-
-
- $this->out->raw(_(' by '));
- $this->out->element('a', array('href' => $app->homepage,
- 'class' => 'h-card'),
- $app->organization);
- }
-
- $readWriteText = _('read-write');
-
- $readOnlyText = _('read-only');
- $access = ($this->connection->access_type & Oauth_application::$writeAccess)
- ? $readWriteText : $readOnlyText;
- $modifiedDate = common_date_string($this->connection->modified);
-
- $txt = sprintf(_('Approved %1$s - "%2$s" access.'), $modifiedDate, $access);
-
- $this->out->raw(" - $txt");
- if (!empty($app->description)) {
- $this->out->element(
- 'p', array('class' => 'application_description'),
- $app->description
- );
- }
- $this->out->element(
- 'p', array(
- 'class' => 'access_token'),
-
-
- sprintf(_('Access token starting with: %s'), substr($this->connection->token, 0, 7))
- );
- $this->out->elementStart(
- 'form',
- array(
- 'id' => 'form_revoke_app',
- 'class' => 'form_revoke_app',
- 'method' => 'POST',
- 'action' => common_local_url('oauthconnectionssettings')
- )
- );
- $this->out->elementStart('fieldset');
- $this->out->hidden('oauth_token', $this->connection->token);
- $this->out->hidden('token', common_session_token());
-
- $this->out->submit('revoke', _m('BUTTON','Revoke'));
- $this->out->elementEnd('fieldset');
- $this->out->elementEnd('form');
- $this->out->elementEnd('li');
- }
- }
|