Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Oauth_Adminhtml_Oauth_Admin_TokenController
  • Mage_Oauth_Adminhtml_Oauth_AuthorizeController
  • Mage_Oauth_Adminhtml_Oauth_AuthorizedTokensController
  • Mage_Oauth_Adminhtml_Oauth_ConsumerController
  • Mage_Oauth_AuthorizeController
  • Mage_Oauth_Block_Adminhtml_Oauth_Admin_Token
  • Mage_Oauth_Block_Adminhtml_Oauth_Admin_Token_Grid
  • Mage_Oauth_Block_Adminhtml_Oauth_Authorize
  • Mage_Oauth_Block_Adminhtml_Oauth_Authorize_Button
  • Mage_Oauth_Block_Adminhtml_Oauth_AuthorizedTokens
  • Mage_Oauth_Block_Adminhtml_Oauth_AuthorizedTokens_Grid
  • Mage_Oauth_Block_Adminhtml_Oauth_Consumer
  • Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Edit
  • Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Edit_Form
  • Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Grid
  • Mage_Oauth_Block_Authorize
  • Mage_Oauth_Block_Authorize_Abstract
  • Mage_Oauth_Block_Authorize_Button
  • Mage_Oauth_Block_Authorize_ButtonBaseAbstract
  • Mage_Oauth_Block_AuthorizeBaseAbstract
  • Mage_Oauth_Block_Customer_Token_List
  • Mage_Oauth_Customer_TokenController
  • Mage_Oauth_Exception
  • Mage_Oauth_Helper_Data
  • Mage_Oauth_InitiateController
  • Mage_Oauth_Model_Consumer
  • Mage_Oauth_Model_Consumer_Validator_KeyLength
  • Mage_Oauth_Model_Nonce
  • Mage_Oauth_Model_Observer
  • Mage_Oauth_Model_Resource_Consumer
  • Mage_Oauth_Model_Resource_Consumer_Collection
  • Mage_Oauth_Model_Resource_Nonce
  • Mage_Oauth_Model_Resource_Nonce_Collection
  • Mage_Oauth_Model_Resource_Setup
  • Mage_Oauth_Model_Resource_Token
  • Mage_Oauth_Model_Resource_Token_Collection
  • Mage_Oauth_Model_Server
  • Mage_Oauth_Model_Token
  • Mage_Oauth_TokenController
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Oauth
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * oAuth My Applications controller
 29:  *
 30:  * Tab "My Applications" in the Customer Account
 31:  *
 32:  * @category    Mage
 33:  * @package     Mage_Oauth
 34:  * @author      Magento Core Team <core@magentocommerce.com>
 35:  */
 36: class Mage_Oauth_Customer_TokenController extends Mage_Core_Controller_Front_Action
 37: {
 38:     /**
 39:      * Customer session model
 40:      *
 41:      * @var Mage_Customer_Model_Session
 42:      */
 43:     protected $_session;
 44: 
 45:     /**
 46:      * Customer session model
 47:      *
 48:      * @var Mage_Customer_Model_Session
 49:      */
 50:     protected $_sessionName = 'customer/session';
 51: 
 52:     /**
 53:      * Check authentication
 54:      *
 55:      * Check customer authentication for some actions
 56:      */
 57:     public function preDispatch()
 58:     {
 59:         parent::preDispatch();
 60:         $this->_session = Mage::getSingleton($this->_sessionName);
 61:         if (!$this->_session->authenticate($this)) {
 62:             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 63:         }
 64: 
 65:     }
 66: 
 67:     /**
 68:      * Render grid page
 69:      */
 70:     public function indexAction()
 71:     {
 72:         $this->loadLayout();
 73:         $this->_initLayoutMessages($this->_sessionName);
 74:         $this->renderLayout();
 75:     }
 76: 
 77:     /**
 78:      * Redirect to referrer URL or otherwise to index page without params
 79:      *
 80:      * @return Mage_Oauth_Customer_TokenController
 81:      */
 82:     protected function _redirectBack()
 83:     {
 84:         $url = $this->_getRefererUrl();
 85:         if (Mage::app()->getStore()->getBaseUrl() == $url) {
 86:             $url = Mage::getUrl('*/*/index');
 87:         }
 88:         $this->_redirectUrl($url);
 89:         return $this;
 90:     }
 91: 
 92:     /**
 93:      * Update revoke status action
 94:      */
 95:     public function revokeAction()
 96:     {
 97:         $id = $this->getRequest()->getParam('id');
 98:         $status = $this->getRequest()->getParam('status');
 99: 
100:         if (0 === (int) $id) {
101:             // No ID
102:             $this->_session->addError($this->__('Invalid entry ID.'));
103:             $this->_redirectBack();
104:             return;
105:         }
106: 
107:         if (null === $status) {
108:             // No status selected
109:             $this->_session->addError($this->__('Invalid revoke status.'));
110:             $this->_redirectBack();
111:             return;
112:         }
113: 
114:         try {
115:             /** @var $collection Mage_Oauth_Model_Resource_Token_Collection */
116:             $collection = Mage::getModel('oauth/token')->getCollection();
117:             $collection->joinConsumerAsApplication()
118:                     ->addFilterByCustomerId($this->_session->getCustomerId())
119:                     ->addFilterById($id)
120:                     ->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS)
121:                     ->addFilterByRevoked(!$status);
122:             //here is can be load from model, but used from collection for get consumer name
123: 
124:             /** @var $model Mage_Oauth_Model_Token */
125:             $model = $collection->getFirstItem();
126:             if ($model->getId()) {
127:                 $name = $model->getName();
128:                 $model->load($model->getId());
129:                 $model->setRevoked($status)->save();
130:                 if ($status) {
131:                     $message = $this->__('Application "%s" has been revoked.', $name);
132:                 } else {
133:                     $message = $this->__('Application "%s" has been enabled.', $name);
134:                 }
135:                 $this->_session->addSuccess($message);
136:             } else {
137:                 $this->_session->addError($this->__('Application not found.'));
138:             }
139:         } catch (Mage_Core_Exception $e) {
140:             $this->_session->addError($e->getMessage());
141:         } catch (Exception $e) {
142:             $this->_session->addError($this->__('An error occurred on update revoke status.'));
143:             Mage::logException($e);
144:         }
145:         $this->_redirectBack();
146:     }
147: 
148:     /**
149:      * Delete action
150:      */
151:     public function deleteAction()
152:     {
153:         $id = $this->getRequest()->getParam('id');
154: 
155:         if (0 === (int) $id) {
156:             // No ID
157:             $this->_session->addError($this->__('Invalid entry ID.'));
158:             $this->_redirectBack();
159:             return;
160:         }
161: 
162:         try {
163:             /** @var $collection Mage_Oauth_Model_Resource_Token_Collection */
164:             $collection = Mage::getModel('oauth/token')->getCollection();
165:             $collection->joinConsumerAsApplication()
166:                     ->addFilterByCustomerId($this->_session->getCustomerId())
167:                     ->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS)
168:                     ->addFilterById($id);
169: 
170:             /** @var $model Mage_Oauth_Model_Token */
171:             $model = $collection->getFirstItem();
172:             if ($model->getId()) {
173:                 $name = $model->getName();
174:                 $model->delete();
175:                 $this->_session->addSuccess(
176:                     $this->__('Application "%s" has been deleted.', $name));
177:             } else {
178:                 $this->_session->addError($this->__('Application not found.'));
179:             }
180:         } catch (Mage_Core_Exception $e) {
181:             $this->_session->addError($e->getMessage());
182:         } catch (Exception $e) {
183:             $this->_session->addError($this->__('An error occurred on delete application.'));
184:             Mage::logException($e);
185:         }
186:         $this->_redirectBack();
187:     }
188: }
189: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0