Esempio n. 1
0
 /**
  * Delete action
  */
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (0 === (int) $id) {
         // No ID
         $this->_session->addError($this->__('Invalid entry ID.'));
         $this->_redirectBack();
         return;
     }
     try {
         /** @var $collection Mage_Oauth_Model_Resource_Token_Collection */
         $collection = Mage::getModel('oauth/token')->getCollection();
         $collection->joinConsumerAsApplication()->addFilterByCustomerId($this->_session->getCustomerId())->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS)->addFilterById($id);
         /** @var $model Mage_Oauth_Model_Token */
         $model = $collection->getFirstItem();
         if ($model->getId()) {
             $name = $model->getName();
             $model->delete();
             $this->_session->addSuccess($this->__('Application "%s" has been deleted.', $name));
         } else {
             $this->_session->addError($this->__('Application not found.'));
         }
     } catch (Mage_Core_Exception $e) {
         $this->_session->addError($e->getMessage());
     } catch (Exception $e) {
         $this->_session->addError($this->__('An error occurred on delete application.'));
         Mage::logException($e);
     }
     $this->_redirectBack();
 }
 /**
  * Request the cancelation of the subscription.
  */
 public function cancelAction()
 {
     if (!$this->_loadValidSubscription()) {
         return;
     }
     $subscription = Mage::registry('current_subscription');
     if ($subscription->canCancel()) {
         $subscription->requestCancel();
         if ($subscription->hasCancelPeriod()) {
             $this->_session->addSuccess(Mage::helper('customweb_subscription')->__('The cancelation request has been received.'));
         } else {
             $this->_session->addSuccess(Mage::helper('customweb_subscription')->__('The subscription has been canceled.'));
         }
     }
     $this->_redirect('*/*/view', array('subscription_id' => $subscription->getId()));
 }
 /**
  * Fetch an update with profile
  */
 public function updateProfileAction()
 {
     $profile = null;
     try {
         $profile = $this->_initProfile();
         $profile->fetchUpdate();
         if ($profile->hasDataChanges()) {
             $profile->save();
             $this->_session->addSuccess($this->__('The profile has been updated.'));
         } else {
             $this->_session->addNotice($this->__('The profile has no changes.'));
         }
     } catch (Mage_Core_Exception $e) {
         $this->_session->addError($e->getMessage());
     } catch (Exception $e) {
         $this->_session->addError($this->__('Failed to update the profile.'));
         Mage::logException($e);
     }
     if ($profile) {
         $this->_redirect('*/*/view', array('profile' => $profile->getId()));
     } else {
         $this->_redirect('*/*/');
     }
 }