diff --git a/source/administrator/components/com_jedchecker/script.php b/source/administrator/components/com_jedchecker/script.php index 68833ec..7b158af 100644 --- a/source/administrator/components/com_jedchecker/script.php +++ b/source/administrator/components/com_jedchecker/script.php @@ -23,6 +23,37 @@ class com_jedcheckerInstallerScript } } + /** + * Update cleans out any old rules. + * + * @param JInstallerComponent $parent Is the class calling this method. + * + * @return bool|null If this returns false, Joomla will abort the update and undo everything already done. + */ + public function update($parent) + { + // Doing it this way in case there are other old rules to be deleted + $oldRules = array('htmlindexes'); + + foreach ($oldRules as $rule) + { + $rulePhpFile = JPATH_ADMINISTRATOR . $this->extension . 'libraries/rules/' . $rule . '.php'; + $ruleIniFile = JPATH_ADMINISTRATOR . $this->extension . 'libraries/rules/' . $rule . '.ini'; + + // Remove the rule's php file + if(file_exists($rulePhpFile) && JFile::delete($rulePhpFile)) + { + echo JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED', $rule); + } + + // Remove the rule's ini file + if(file_exists($rulePhpFile) && JFile::delete($rulePhpFile)) + { + echo JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED', $rule); + } + + } + } public function loadLanguage() { diff --git a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini index 66d3c65..1cbaad6 100644 --- a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini +++ b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini @@ -44,4 +44,6 @@ COM_JEDCHECKER_RULE_PH1_DESC="A notice is required on each PHP file stating that COM_JEDCHECKER_ERROR_GPL_NOT_FOUND="GPL or compatible license was not found" COM_JEDCHECKER_PH1_LICENSE_FOUND="GPL license was found" COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND="GPL compatible license was found" -COM_JEDCHECKER_WARNING="Warning" \ No newline at end of file +COM_JEDCHECKER_WARNING="Warning" +COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED="Removed PHP file for '%1' rule." +COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED="Removed 'ini' file for '%1' rule." \ No newline at end of file