private function _shInstallModule($module, $source, $extensionConfig, $moduleConfig)
 {
     $app = JFactory::getApplication();
     $path = $source . '/admin/modules/' . $module;
     $installer = new JInstaller();
     $result = $installer->install($path);
     if ($result) {
         // if files moved to destination, setup module in Joomla database
         $shouldRestore = $this->_shShouldRestore();
         if ($shouldRestore) {
             // read stored params from disk
             $this->_shGetExtensionSavedParams($module . '_extension', $extensionConfig);
         }
         // update elements in db, only if we need to restore past configuration
         try {
             if (!empty($extensionConfig)) {
                 // load module details from extension table
                 $moduleDetails = ShlDbHelper::selectAssoc('#__extensions', array('*'), array('type' => 'module', 'element' => $module));
                 // merge with saved details and write back to disk
                 $details = array_merge($moduleDetails, $extensionConfig);
                 ShlDbHelper::update('#__extensions', $details, array('extension_id' => (int) $moduleDetails['extension_id']));
             }
         } catch (Exception $e) {
             $app->enqueueMessage('Error: ' . $e->getMessage());
         }
         if ($shouldRestore) {
             // read stored params from disk
             $this->_shGetExtensionSavedParams($module . '_modules', $moduleConfig);
         }
         // update elements in db, if we need to restore past configuration
         try {
             $instanceDetails = ShlDbHelper::selectAssoc('#__modules', array('*'), array('module' => $module));
             // merge with saved details and write back to disk
             $details = array_merge($instanceDetails, $moduleConfig);
             ShlDbHelper::update('#__modules', $details, array('id' => (int) $instanceDetails['id']));
         } catch (Exception $e) {
             $app->enqueueMessage('Error: ' . $e->getMessage());
         }
         // and finally we make sure there is a menu item associated with the module
         $details = array('menuid' => 0);
         if ($shouldRestore) {
             // read stored params from disk
             $this->_shGetExtensionSavedParams($module . '_modules_menu', $details);
         }
         $details = array_merge($details, array('moduleid' => (int) $instanceDetails['id']));
         // insert or update elements in db, if we need to restore past configuration
         try {
             ShlDbHelper::insertUpdate('#__modules_menu', $details, array('moduleid' => (int) $instanceDetails['id']));
         } catch (Exception $e) {
             $app->enqueueMessage('Error: ' . $e->getMessage());
         }
     } else {
         $app->enqueueMessage('Error installing sh404sef module: ' . $module);
     }
     return $result;
 }