Skip to content

Commit

Permalink
Fixed issue in cleanModuleList
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter van Westen committed Mar 5, 2015
1 parent 1101a04 commit bef6899
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libraries/cms/module/helper.php
Expand Up @@ -349,12 +349,12 @@ protected static function &load()
// If the onPrepareModuleList event returns an array of modules, then ignore the default module list creation
if (!is_array($modules))
{
$modules = self::getModuleList();
$modules = static::getModuleList();
}

$app->triggerEvent('onAfterModuleList', array(&$modules));

$modules = self::cleanModuleList($modules);
$modules = static::cleanModuleList($modules);

$app->triggerEvent('onAfterCleanModuleList', array(&$modules));

Expand Down Expand Up @@ -428,9 +428,10 @@ public static function cleanModuleList($modules)
// Apply negative selections and eliminate duplicates
$Itemid = JFactory::getApplication()->input->getInt('Itemid');
$negId = $Itemid ? -(int) $Itemid : false;
$clean = array();
$dupes = array();

foreach ($modules as $i => &$module)
foreach ($modules as $i => $module)
{
// The module is excluded if there is an explicit prohibition
$negHit = ($negId === (int) $module->menuid);
Expand All @@ -441,7 +442,7 @@ public static function cleanModuleList($modules)
// but remove any item from the modules array.
if ($negHit)
{
unset($modules[$i]);
unset($clean[$module->id]);
}

continue;
Expand All @@ -452,20 +453,20 @@ public static function cleanModuleList($modules)
// Only accept modules without explicit exclusions.
if ($negHit)
{
unset($modules[$i]);

continue;
}

$module->name = substr($module->module, 4);
$module->style = null;
$module->position = strtolower($module->position);

$clean[$module->id] = $module;
}

unset($dupes);

// Return to simple indexing that matches the query order.
return array_values($modules);
return array_values($clean);
}

/**
Expand Down

0 comments on commit bef6899

Please sign in to comment.