31
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-05-31 21:00:47 +00:00
patchtester/administrator/components/com_patchtester/controllers/pull.php

59 lines
1.2 KiB
PHP
Raw Normal View History

2011-10-11 13:02:57 +00:00
<?php
/**
2012-06-12 18:42:45 +00:00
* @package PatchTester
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
2011-10-11 13:02:57 +00:00
*/
// No direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controllerform');
/**
* Pull controller class
*
2012-06-12 18:42:45 +00:00
* @package PatchTester
2011-10-11 13:02:57 +00:00
*/
class PatchtesterControllerPull extends JController
{
public function apply()
{
2012-06-12 18:42:45 +00:00
try
{
$this->getModel('pull')
->apply(JRequest::getVar('pull_id'));
2011-10-11 13:02:57 +00:00
$msg = 'Patch successfully applied';
$type = 'message';
2012-06-12 18:42:45 +00:00
}
catch (Exception $e)
{
$msg = $e->getMessage();
$type = 'error';
2011-10-11 13:02:57 +00:00
}
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
2011-10-11 13:02:57 +00:00
}
public function revert()
{
2012-06-12 18:42:45 +00:00
try
{
$this->getModel('pull')
->revert(JRequest::getVar('pull_id'));
2011-10-11 13:02:57 +00:00
$msg = 'Patch successfully reverted';
$type = 'message';
2012-06-12 18:42:45 +00:00
}
catch (Exception $e)
{
$msg = $e->getMessage() ?: 'Patch did not revert';
$type = 'error';
2011-10-11 13:02:57 +00:00
}
2012-06-12 18:42:45 +00:00
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
2011-10-11 13:02:57 +00:00
}
}