X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fshowapplication.php;h=b9e3b329146dc3e18020477eb67eea56129c4d44;hb=5c25364141eca62ea99c4f81d55ab592273db518;hp=b21b994aa23af13f5f2db476f77d11652d8c3fd5;hpb=ba68e042a8acb9dd1054e0bc1c5cd4dfd415642e;p=quix0rs-gnu-social.git diff --git a/actions/showapplication.php b/actions/showapplication.php index b21b994aa2..b9e3b32914 100644 --- a/actions/showapplication.php +++ b/actions/showapplication.php @@ -92,6 +92,7 @@ class ShowApplicationAction extends OwnerDesignAction if ($cur->id != $this->owner->id) { $this->clientError(_('You are not the owner of this application.'), 401); + return false; } return true; @@ -148,49 +149,30 @@ class ShowApplicationAction extends OwnerDesignAction function showContent() { - $cur = common_current_user(); $consumer = $this->application->getConsumer(); $this->elementStart('div', 'entity_profile vcard'); $this->element('h2', null, _('Application profile')); - $this->elementStart('dl', 'entity_depiction'); - $this->element('dt', null, _('Icon')); - $this->elementStart('dd'); if (!empty($this->application->icon)) { $this->element('img', array('src' => $this->application->icon, - 'class' => 'photo logo')); + 'class' => 'photo logo entity_depiction')); } - $this->elementEnd('dd'); - $this->elementEnd('dl'); - $this->elementStart('dl', 'entity_fn'); - $this->element('dt', null, _('Name')); - $this->elementStart('dd'); $this->element('a', array('href' => $this->application->source_url, - 'class' => 'url fn'), + 'class' => 'url fn entity_fn'), $this->application->name); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - $this->elementStart('dl', 'entity_org'); - $this->element('dt', null, _('Organization')); - $this->elementStart('dd'); $this->element('a', array('href' => $this->application->homepage, - 'class' => 'url'), + 'class' => 'url entity_org'), $this->application->organization); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - $this->elementStart('dl', 'entity_note'); - $this->element('dt', null, _('Description')); - $this->element('dd', 'note', $this->application->description); - $this->elementEnd('dl'); + $this->element('div', + 'note entity_note', + $this->application->description); - $this->elementStart('dl', 'entity_statistics'); - $this->element('dt', null, _('Statistics')); - $this->elementStart('dd'); + $this->elementStart('div', 'entity_statistics'); $defaultAccess = ($this->application->access_type & Oauth_application::$writeAccess) ? 'read-write' : 'read-only'; $profile = Profile::staticGet($this->application->owner); @@ -200,13 +182,13 @@ class ShowApplicationAction extends OwnerDesignAction $userCnt = $appUsers->count(); $this->raw(sprintf( - _('created by %1$s - %2$s access by default - %3$d users'), + _('Created by %1$s - %2$s access by default - %3$d users'), $profile->getBestName(), $defaultAccess, $userCnt )); - $this->elementEnd('dd'); - $this->elementEnd('dl'); + $this->elementEnd('div'); + $this->elementEnd('div'); $this->elementStart('div', 'entity_actions'); @@ -221,50 +203,62 @@ class ShowApplicationAction extends OwnerDesignAction $this->elementStart('li', 'entity_reset_keysecret'); $this->elementStart('form', array( - 'id' => 'forma_reset_key', + 'id' => 'form_reset_key', 'class' => 'form_reset_key', 'method' => 'POST', 'action' => common_local_url('showapplication', array('id' => $this->application->id)))); + $this->elementStart('fieldset'); + $this->hidden('token', common_session_token()); + + $this->element('input', array('type' => 'submit', + 'id' => 'reset', + 'name' => 'reset', + 'class' => 'submit', + 'value' => _('Reset key & secret'), + 'onClick' => 'return confirmReset()')); + $this->elementEnd('fieldset'); + $this->elementEnd('form'); + $this->elementEnd('li'); + + $this->elementStart('li', 'entity_delete'); + $this->elementStart('form', array( + 'id' => 'form_delete_application', + 'class' => 'form_delete_application', + 'method' => 'POST', + 'action' => common_local_url('deleteapplication', + array('id' => $this->application->id)))); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); - $this->submit('reset', _('Reset key & secret')); + $this->submit('delete', _('Delete')); $this->elementEnd('fieldset'); $this->elementEnd('form'); $this->elementEnd('li'); + $this->elementEnd('ul'); $this->elementEnd('div'); $this->elementStart('div', 'entity_data'); $this->element('h2', null, _('Application info')); - $this->elementStart('dl', 'entity_consumer_key'); - $this->element('dt', null, _('Consumer key')); - $this->element('dd', null, $consumer->consumer_key); - $this->elementEnd('dl'); - - $this->elementStart('dl', 'entity_consumer_secret'); - $this->element('dt', null, _('Consumer secret')); - $this->element('dd', null, $consumer->consumer_secret); - $this->elementEnd('dl'); - - $this->elementStart('dl', 'entity_request_token_url'); - $this->element('dt', null, _('Request token URL')); - $this->element('dd', null, common_local_url('apioauthrequesttoken')); - $this->elementEnd('dl'); - - $this->elementStart('dl', 'entity_access_token_url'); - $this->element('dt', null, _('Access token URL')); - $this->element('dd', null, common_local_url('apioauthaccesstoken')); - $this->elementEnd('dl'); - - $this->elementStart('dl', 'entity_authorize_url'); - $this->element('dt', null, _('Authorize URL')); - $this->element('dd', null, common_local_url('apioauthauthorize')); - $this->elementEnd('dl'); + $this->element('div', + 'entity_consumer_key', + $consumer->consumer_key); + + $this->element('div', + 'entity_consumer_secret', + $consumer->consumer_secret); + + $this->element('div', + 'entity_request_token_url', + common_local_url('ApiOauthRequestToken')); + + $this->element('div', 'entity_access_token_url', common_local_url('ApiOauthAccessToken')); + + $this->element('div', 'entity_authorize_url', common_local_url('ApiOauthAuthorize')); $this->element('p', 'note', - _('Note: We support hmac-sha1 signatures. We do not support the plaintext signature method.')); + _('Note: We support HMAC-SHA1 signatures. We do not support the plaintext signature method.')); $this->elementEnd('div'); $this->elementStart('p', array('id' => 'application_action')); @@ -275,14 +269,53 @@ class ShowApplicationAction extends OwnerDesignAction $this->elementEnd('p'); } + /** + * Add a confirm script for Consumer key/secret reset + * + * @return void + */ + + function showScripts() + { + parent::showScripts(); + + $msg = _('Are you sure you want to reset your consumer key and secret?'); + + $js = 'function confirmReset() { '; + $js .= ' var agree = confirm("' . $msg . '"); '; + $js .= ' return agree;'; + $js .= '}'; + + $this->inlineScript($js); + } + + /** + * Reset an application's Consumer key and secret + * + * XXX: Should this be moved to its own page with a confirm? + * + */ + function resetKey() { $this->application->query('BEGIN'); + $oauser = new Oauth_application_user(); + $oauser->application_id = $this->application->id; + $result = $oauser->delete(); + + if ($result === false) { + common_log_db_error($oauser, 'DELETE', __FILE__); + $this->success = false; + $this->msg = ('Unable to reset consumer key and secret.'); + $this->showPage(); + return; + } + $consumer = $this->application->getConsumer(); $result = $consumer->delete(); - if (!$result) { + if ($result === false) { common_log_db_error($consumer, 'DELETE', __FILE__); $this->success = false; $this->msg = ('Unable to reset consumer key and secret.'); @@ -294,7 +327,7 @@ class ShowApplicationAction extends OwnerDesignAction $result = $consumer->insert(); - if (!$result) { + if (empty($result)) { common_log_db_error($consumer, 'INSERT', __FILE__); $this->application->query('ROLLBACK'); $this->success = false; @@ -307,7 +340,7 @@ class ShowApplicationAction extends OwnerDesignAction $this->application->consumer_key = $consumer->consumer_key; $result = $this->application->update($orig); - if (!$result) { + if ($result === false) { common_log_db_error($application, 'UPDATE', __FILE__); $this->application->query('ROLLBACK'); $this->success = false; @@ -324,4 +357,3 @@ class ShowApplicationAction extends OwnerDesignAction } } -