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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PatchTester Controller
|
|
|
|
*
|
2012-06-12 18:42:45 +00:00
|
|
|
* @package PatchTester
|
2013-07-13 02:26:21 +00:00
|
|
|
* @since 1.0
|
2011-10-11 13:02:57 +00:00
|
|
|
*/
|
2012-09-09 01:53:44 +00:00
|
|
|
class PatchTesterController extends JControllerLegacy
|
2011-10-11 13:02:57 +00:00
|
|
|
{
|
|
|
|
/**
|
2013-07-13 02:26:21 +00:00
|
|
|
* The default view for the display method.
|
2011-10-11 13:02:57 +00:00
|
|
|
*
|
2013-07-13 02:26:21 +00:00
|
|
|
* @var string
|
|
|
|
* @since 1.0
|
2011-10-11 13:02:57 +00:00
|
|
|
*/
|
2013-07-13 02:26:21 +00:00
|
|
|
protected $default_view = 'pulls';
|
2013-07-14 19:34:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to purge the cache
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
public function purge()
|
|
|
|
{
|
|
|
|
// Check for request forgeries
|
|
|
|
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
|
|
|
|
|
|
|
jimport('joomla.filesystem.file');
|
2013-07-19 03:11:51 +00:00
|
|
|
jimport('joomla.filesystem.folder');
|
2013-07-14 19:34:29 +00:00
|
|
|
|
2013-07-19 03:11:51 +00:00
|
|
|
$failures = 0;
|
|
|
|
$successes = 0;
|
|
|
|
|
|
|
|
$cacheFiles = JFolder::files(JPATH_CACHE);
|
|
|
|
|
|
|
|
foreach ($cacheFiles as $file)
|
|
|
|
{
|
|
|
|
if (strpos($file, 'patchtester-page-') === 0)
|
|
|
|
{
|
|
|
|
if (!JFile::delete(JPATH_CACHE . '/' . $file))
|
|
|
|
{
|
|
|
|
$failures++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$successes++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($failures > 0)
|
2013-07-14 19:34:29 +00:00
|
|
|
{
|
2013-07-19 03:11:51 +00:00
|
|
|
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_FAIL', $failures), 'error');
|
2013-07-14 19:34:29 +00:00
|
|
|
}
|
2013-07-19 03:11:51 +00:00
|
|
|
|
|
|
|
if ($successes > 0)
|
|
|
|
{
|
|
|
|
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_SUCCESS', $successes), 'message');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($failures == 0 && $successes == 0)
|
2013-07-14 19:34:29 +00:00
|
|
|
{
|
2013-07-19 03:11:51 +00:00
|
|
|
JFactory::getApplication()->enqueueMessage(JText::_('COM_PATCHTESTER_PURGE_NA'), 'message');
|
2013-07-14 19:34:29 +00:00
|
|
|
}
|
|
|
|
|
2013-07-19 03:11:51 +00:00
|
|
|
$this->setRedirect('index.php?option=com_patchtester&view=pulls');
|
2013-07-14 19:34:29 +00:00
|
|
|
}
|
2011-10-11 13:02:57 +00:00
|
|
|
}
|