Skip to content

Commit

Permalink
Commit initial du module Cybermut
Browse files Browse the repository at this point in the history
  • Loading branch information
Marine PASQUIN committed Jun 20, 2013
1 parent 7c50cff commit 9bd899f
Show file tree
Hide file tree
Showing 34 changed files with 2,482 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/code/community/Quadra/Cybermut/Block/Error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Block_Error extends Mage_Core_Block_Template
{
}
25 changes: 25 additions & 0 deletions app/code/community/Quadra/Cybermut/Block/Form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Block_Form extends Mage_Payment_Block_Form
{
protected function _construct()
{
$this->setTemplate('cybermut/form.phtml');
parent::_construct();
}
}
50 changes: 50 additions & 0 deletions app/code/community/Quadra/Cybermut/Block/Redirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Block_Redirect extends Mage_Core_Block_Abstract
{

protected function _toHtml()
{
$standard = Mage::getModel('cybermut/payment');
$form = new Varien_Data_Form();
$form->setAction($standard->getCybermutUrl())
->setId('cybermut_payment_checkout')
->setName('cybermut_payment_checkout')
->setMethod('POST')
->setUseContainer(true);
foreach ($standard->setOrder($this->getOrder())->getStandardCheckoutFormFields() as $field => $value) {
$form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
}

$formHTML = $form->toHtml();

$html = '<html><body>';
$html.= $this->__('You will be redirected to Cybermut in a few seconds.');
$html.= $formHTML;
$html.= '<script type="text/javascript">document.getElementById("cybermut_payment_checkout").submit();</script>';
$html.= '</body></html>';

if ($standard->getConfigData('debug_flag')) {
Mage::getModel('cybermut/api_debug')
->setRequestBody($formHTML)
->save();
}

return $html;
}
}
21 changes: 21 additions & 0 deletions app/code/community/Quadra/Cybermut/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Helper_Data extends Mage_Core_Helper_Abstract
{

}
24 changes: 24 additions & 0 deletions app/code/community/Quadra/Cybermut/Model/Api/Debug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Model_Api_Debug extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init('cybermut/api_debug');
}
}
29 changes: 29 additions & 0 deletions app/code/community/Quadra/Cybermut/Model/Config/Data/Cybermut.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Model_Config_Data_Cybermut extends Mage_Core_Model_Config_Data
{
public function _beforeSave() {
$filename = BP . DS . 'app' . DS . 'code' . DS . 'local' . DS . 'Mage' . DS . 'Cybermut' . DS . 'etc' . DS . 'config.xml';

if (file_exists($filename)) {
Mage::getSingleton('adminhtml/session')->addError('Warning: the module Mage_Cybermut must be uninstalled.');
}

return $this;
}
}
24 changes: 24 additions & 0 deletions app/code/community/Quadra/Cybermut/Model/Mysql4/Api/Debug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
{
protected function _construct()
{
$this->_init('cybermut/api_debug', 'debug_id');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
protected function _construct()
{
$this->_init('cybermut/api_debug');
}
}
20 changes: 20 additions & 0 deletions app/code/community/Quadra/Cybermut/Model/Mysql4/Setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Model_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
{
}
68 changes: 68 additions & 0 deletions app/code/community/Quadra/Cybermut/Model/Observer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/*
* 1997-2012 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author Quadra Informatique <[email protected]>
* @copyright 1997-2013 Quadra Informatique
* @version Release: $Revision: 2.0.5 $
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

class Quadra_Cybermut_Model_Observer
{
/**
* Can redirect to Cybermut payment
*/
public function initRedirect(Varien_Event_Observer $observer)
{
Mage::getSingleton('checkout/session')->setCanRedirect(true);
}

/**
* Return Orders Redirect URL
*
* @return string Orders Redirect URL
*/
public function multishippingRedirectUrl(Varien_Event_Observer $observer)
{
if (Mage::getSingleton('checkout/session')->getCanRedirect()) {
$orderIds = Mage::getSingleton('core/session')->getOrderIds();
$orderIdsTmp = $orderIds;
$key = array_pop($orderIdsTmp);
$order = Mage::getModel('sales/order')->loadByIncrementId($key);

if (!(strpos($order->getPayment()->getMethod(), 'cybermut') === false)) {
Mage::getSingleton('checkout/session')->setRealOrderIds(implode(',', $orderIds));
Mage::app()->getResponse()->setRedirect(Mage::getUrl('cybermut/payment/redirect'));
}
} else {
Mage::getSingleton('checkout/session')->unsRealOrderIds();
}

return $this;
}

/**
* Disables sending email after the order creation
*
* @return updated order
*/
public function disableEmailForMultishipping(Varien_Event_Observer $observer)
{
$order = $observer->getOrder();

if (!(strpos($order->getPayment()->getMethod(), 'cybermut') === false)) {
$order->setCanSendNewEmailFlag(false)->save();
}

return $this;
}

}
Loading

0 comments on commit 9bd899f

Please sign in to comment.