123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class DeleteapplicationAction extends Action
- {
- var $app = null;
-
- function prepare(array $args = array())
- {
- if (!parent::prepare($args)) {
- return false;
- }
- if (!common_logged_in()) {
-
- $this->clientError(_('You must be logged in to delete an application.'));
- }
- $id = (int)$this->arg('id');
- $this->app = Oauth_application::getKV('id', $id);
- if (empty($this->app)) {
-
- $this->clientError(_('Application not found.'));
- }
- $cur = common_current_user();
- if ($cur->id != $this->app->owner) {
-
- $this->clientError(_('You are not the owner of this application.'), 401);
- }
- return true;
- }
-
- function handle()
- {
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token.'));
- }
- if ($this->arg('no')) {
- common_redirect(common_local_url('showapplication',
- array('id' => $this->app->id)), 303);
- } elseif ($this->arg('yes')) {
- $this->handlePost();
- common_redirect(common_local_url('oauthappssettings'), 303);
- } else {
- $this->showPage();
- }
- }
- }
- function showContent() {
- $this->areYouSureForm();
- }
- function title() {
-
- return _('Delete application');
- }
- function showNoticeForm() {
-
- }
-
- function areYouSureForm()
- {
- $id = $this->app->id;
- $this->elementStart('form', array('id' => 'deleteapplication-' . $id,
- 'method' => 'post',
- 'class' => 'form_settings form_entity_block',
- 'action' => common_local_url('deleteapplication',
- array('id' => $this->app->id))));
- $this->elementStart('fieldset');
- $this->hidden('token', common_session_token());
-
- $this->element('legend', _('Delete application'));
- $this->element('p', null,
-
- _('Are you sure you want to delete this application? '.
- 'This will clear all data about the application from the '.
- 'database, including all existing user connections.'));
- $this->submit('form_action-no',
-
- _m('BUTTON','No'),
- 'submit form_action-primary',
- 'no',
-
- _('Do not delete this application.'));
- $this->submit('form_action-yes',
-
- _m('BUTTON','Yes'),
- 'submit form_action-secondary',
-
- 'yes', _('Delete this application.'));
- $this->elementEnd('fieldset');
- $this->elementEnd('form');
- }
-
- function handlePost()
- {
- $this->app->delete();
- }
- }
|