2011-10-11 13:02:57 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2013-07-13 02:26:21 +00:00
|
|
|
* @package PatchTester
|
|
|
|
*
|
2014-01-03 02:48:28 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2014 Open Source Matters, Inc. All rights reserved.
|
2013-07-13 02:26:21 +00:00
|
|
|
* @license GNU General Public License version 2 or later
|
2011-10-11 13:02:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pull controller class
|
|
|
|
*
|
2013-07-13 02:26:21 +00:00
|
|
|
* @package PatchTester
|
|
|
|
* @since 1.0
|
2011-10-11 13:02:57 +00:00
|
|
|
*/
|
2012-09-09 01:53:44 +00:00
|
|
|
class PatchtesterControllerPull extends JControllerLegacy
|
2011-10-11 13:02:57 +00:00
|
|
|
{
|
2013-07-13 02:26:21 +00:00
|
|
|
/**
|
|
|
|
* Method to apply a patch
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
2011-10-11 13:02:57 +00:00
|
|
|
public function apply()
|
|
|
|
{
|
2012-06-12 18:42:45 +00:00
|
|
|
try
|
|
|
|
{
|
2013-07-13 02:26:21 +00:00
|
|
|
$this->getModel('pull')->apply(JFactory::getApplication()->input->getInt('pull_id'));
|
2011-10-15 01:13:59 +00:00
|
|
|
|
2013-07-13 02:26:21 +00:00
|
|
|
$msg = JText::_('COM_PATCHTESTER_APPLY_OK');
|
2013-07-12 01:49:58 +00:00
|
|
|
$type = 'message';
|
2012-06-12 18:42:45 +00:00
|
|
|
}
|
|
|
|
catch (Exception $e)
|
|
|
|
{
|
2013-07-13 02:26:21 +00:00
|
|
|
$msg = $e->getMessage();
|
2011-10-13 04:01:15 +00:00
|
|
|
$type = 'error';
|
2011-10-11 13:02:57 +00:00
|
|
|
}
|
2011-10-15 01:13:59 +00:00
|
|
|
|
2011-10-13 04:01:15 +00:00
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
|
2011-10-11 13:02:57 +00:00
|
|
|
}
|
|
|
|
|
2013-07-13 02:26:21 +00:00
|
|
|
/**
|
|
|
|
* Method to revert a patch
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
2011-10-11 13:02:57 +00:00
|
|
|
public function revert()
|
|
|
|
{
|
2012-06-12 18:42:45 +00:00
|
|
|
try
|
|
|
|
{
|
2013-07-13 02:26:21 +00:00
|
|
|
$this->getModel('pull')->revert(JFactory::getApplication()->input->getInt('pull_id'));
|
2012-06-12 18:42:45 +00:00
|
|
|
|
2013-07-13 02:26:21 +00:00
|
|
|
$msg = JText::_('COM_PATCHTESTER_REVERT_OK');
|
2013-07-12 01:49:58 +00:00
|
|
|
$type = 'message';
|
2012-06-12 18:42:45 +00:00
|
|
|
}
|
|
|
|
catch (Exception $e)
|
|
|
|
{
|
2013-07-13 02:26:21 +00:00
|
|
|
$msg = $e->getMessage();
|
2011-10-13 04:01:15 +00:00
|
|
|
$type = 'error';
|
2011-10-11 13:02:57 +00:00
|
|
|
}
|
2012-06-12 18:42:45 +00:00
|
|
|
|
2011-10-13 04:01:15 +00:00
|
|
|
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
|
2011-10-11 13:02:57 +00:00
|
|
|
}
|
|
|
|
}
|