/** * Delete a list of urls from their ids, * passed as params * Also delete all duplicates * * @param array of integer $ids the list of url id to delete * @return boolean true if success */ public function deleteByIdsWithDuplicates($ids = array()) { if (empty($ids)) { return true; } // build a list of ids to read $whereIds = Sh404sefHelperDb::arrayToIntValList($ids); // read urls and their duplicates $query = 'select r2.id' . ' from `#__redirection` as r1' . ' join `#__redirection` as r2' . ' on r1.`oldurl` = r2.`oldurl`' . ' where r1.' . $this->_db->nameQuote('id') . ' in (' . $whereIds . ')'; // perform query $this->_db->setQuery($query); $urlsIds = $this->_db->loadResultArray(); // now delete urls from db and cache $rows = $this->_getNonSefUrls($urlsIds); if (!empty($rows)) { Sh404sefHelperCache::removeURLFromCache($rows); } // finally, we can simply delete from db by ids try { sh404sefHelperDb::deleteIn('#__redirection', 'id', $urlsIds); } catch (Sh404sefExceptionDefault $e) { $this->setError('Internal database error # ' . $e->getMessage()); } return true; }
private function _shInstallModule($module, $source, $extensionConfig, $moduleConfig) { $app =& JFactory::getApplication(); $path = $source . DS . 'admin' . DS . 'modules' . DS . $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 = Sh404sefHelperDb::selectAssoc('#__extensions', array('*'), array('type' => 'module', 'element' => $module)); // merge with saved details and write back to disk $details = array_merge($moduleDetails, $extensionConfig); Sh404sefHelperDb::update('#__extensions', $details, array('extension_id' => (int) $moduleDetails['extension_id'])); } } catch (Sh404sefExceptionDefault $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 = Sh404sefHelperDb::selectAssoc('#__modules', array('*'), array('module' => $module)); // merge with saved details and write back to disk $details = array_merge($instanceDetails, $moduleConfig); Sh404sefHelperDb::update('#__modules', $details, array('id' => (int) $instanceDetails['id'])); } catch (Sh404sefExceptionDefault $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 { sh404sefHelperDb::insertUpdate('#__modules_menu', $details, array('moduleid' => (int) $instanceDetails['id'])); } catch (Sh404sefExceptionDefault $e) { $app->enqueueMessage('Error: ' . $e->getMessage()); } } else { $app->enqueueMessage('Error installing sh404sef module: ' . $module); } return $result; }