Skip to content

Commit

Permalink
Clean up ModulesModelModule class
Browse files Browse the repository at this point in the history
  • Loading branch information
joomdonation authored Dec 27, 2016
1 parent 9236b72 commit 9d65eb4
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions administrator/components/com_modules/models/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ public function duplicate(&$pks)
->from($db->quoteName('#__modules_menu'))
->where($db->quoteName('moduleid') . ' = ' . (int) $pk);

$this->_db->setQuery($query);
$rows = $this->_db->loadColumn();
$db->setQuery($query);
$rows = $db->loadColumn();

foreach ($rows as $menuid)
{
Expand All @@ -448,11 +448,11 @@ public function duplicate(&$pks)
->columns($db->quoteName(array('moduleid', 'menuid')))
->values($tuples);

$this->_db->setQuery($query);
$db->setQuery($query);

try
{
$this->_db->execute();
$db->execute();
}
catch (RuntimeException $e)
{
Expand Down Expand Up @@ -686,8 +686,7 @@ public function getItem($pk = null)
}
else
{
$app = JFactory::getApplication();
$app->redirect(JRoute::_('index.php?option=com_modules&view=modules', false));
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_modules&view=modules', false));

return false;
}
Expand Down Expand Up @@ -1016,18 +1015,16 @@ public function save($data)
// Get the sign of the number.
$sign = $assignment < 0 ? -1 : 1;

// Preprocess the assigned array.
$tuples = array();
$query->clear()
->insert($db->quoteName('#__modules_menu'))
->columns($db->quoteName(array('moduleid', 'menuid')));

foreach ($data['assigned'] as &$pk)
{
$tuples[] = '(' . (int) $table->id . ',' . (int) $pk * $sign . ')';
$query->values((int) $table->id . ',' . (int) $pk * $sign);
}

$this->_db->setQuery(
'INSERT INTO #__modules_menu (moduleid, menuid) VALUES ' .
implode(',', $tuples)
);
$db->setQuery($query);

try
{
Expand All @@ -1046,7 +1043,7 @@ public function save($data)
$dispatcher->trigger($this->event_after_save, array($context, &$table, $isNew));

// Compute the extension id of this module in case the controller wants it.
$query = $db->getQuery(true)
$query->clear()
->select('extension_id')
->from('#__extensions AS e')
->join('LEFT', '#__modules AS m ON e.element = m.module')
Expand Down

0 comments on commit 9d65eb4

Please sign in to comment.