Skip to content

Commit

Permalink
Merge pull request #6 from zero-24/patch-4
Browse files Browse the repository at this point in the history
First try :)
  • Loading branch information
brianteeman committed Jul 17, 2015
2 parents 4e60231 + 763a9c2 commit 2714699
Showing 1 changed file with 34 additions and 26 deletions.
60 changes: 34 additions & 26 deletions plugins/quickicon/maxvars/maxvars.php
@@ -1,10 +1,10 @@
<?php
/**
* @package Joomla.Plugin
* @package Joomla.Plugin
* @subpackage Quickicon.Joomla
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
Expand All @@ -14,7 +14,6 @@
*
* @since 3.5
*/

class PlgQuickiconMaxvars extends JPlugin
{
/**
Expand All @@ -25,7 +24,7 @@ class PlgQuickiconMaxvars extends JPlugin
* Recognized key values include 'name', 'group', 'params', 'language'
* (this list is not meant to be comprehensive).
*
* @since 2.5.28
* @since 3.5
*/
public function __construct(&$subject, $config = array())
{
Expand All @@ -44,33 +43,42 @@ public function __construct(&$subject, $config = array())
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*
* @since 2.5.28
* @since 3.5
*/
public function onGetIcons($context)
public function onGetIcons($context)
{
$text = JText::_('PLG_MAX_VARS');
$maxinputvars = @ini_get('max_input_vars');
$varcount = 0;

$tables = array(
'#__categories',
'#__menu',
'#__modules',
'#__usergroups',
);

// Get a db connection.
$db = JFactory::getDbo();

$text = JText::_('PLG_MAX_VARS');
$maxinputvars = ini_get('max_input_vars');
$varcount =
SELECT SUM(count) FROM (
SELECT count(*) as count FROM `#_categories` as a
UNION
SELECT count(*) as count FROM `#_menu` as b
UNION
SELECT count(*) as count FROM `#_modules` as c
UNION
SELECT count(*) as count FROM `#_usergroups` as d
) as varcount;
if $varcount >= $maxinputvars
foreach ($tables as $tableToCheck)
{
// Create a new query object.
$query = $db->getQuery(true);

$query->select($db->quoteName('id'));
$query->from($db->quoteName($tableToCheck));

$db->setQuery($query);
$db->execute();
$varcount = $varcount + $db->getNumRows();
}

if ($varcount >= $maxinputvars)
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_MAX_VARS_FAIL', $text), 'error');
}

// then test if $varcount is within 10% of $maxinputvars and PLG_MAX_VARS_WARN


}



}

0 comments on commit 2714699

Please sign in to comment.