123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ConnectedAppsList extends Widget
- {
-
- var $connection = null;
-
- var $owner = null;
- function __construct($connection, Profile $owner, Action $out=null)
- {
- parent::__construct($out);
- common_debug("ConnectedAppsList constructor");
- $this->connection = $connection;
- $this->owner = $owner;
- }
-
- 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');
- }
- }
|