diff --git a/administrator/components/com_modules/models/module.php b/administrator/components/com_modules/models/module.php index 39a19fabeb607..89b8db45bf0a5 100644 --- a/administrator/components/com_modules/models/module.php +++ b/administrator/components/com_modules/models/module.php @@ -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) { @@ -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) { @@ -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; } @@ -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 { @@ -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')