|
From: <be...@us...> - 2014-06-22 02:35:50
|
Revision: 12628
http://sourceforge.net/p/xoops/svn/12628
Author: beckmi
Date: 2014-06-22 02:35:42 +0000 (Sun, 22 Jun 2014)
Log Message:
-----------
adding clean-up routine for old directories/files
Modified Paths:
--------------
XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/include/update.php
Modified: XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/include/update.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/include/update.php 2014-06-22 02:18:47 UTC (rev 12627)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/include/update.php 2014-06-22 02:35:42 UTC (rev 12628)
@@ -16,9 +16,53 @@
* @version $Id$
*/
-function xoops_module_update_publisher($module, $version)
+function xoops_module_update_publisher($module, $oldversion = null)
{
+
+ if ($oldversion < 102) {
+ // delete old html template files
+ $templateDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/templates/";
+ $template_list = array_diff(scandir($templateDirectory), array('..', '.'));
+ foreach ($template_list as $k => $v) {
+ $fileinfo = new SplFileInfo($templateDirectory . $v);
+ if ($fileinfo->getExtension() == 'html' && $fileinfo->getFilename() != 'index.html') {
+ @unlink($templateDirectory . $v);
+ }
+ }
+ // delete old block html template files
+ $templateDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/templates/blocks/";
+ $template_list = array_diff(scandir($templateDirectory), array('..', '.'));
+ foreach ($template_list as $k => $v) {
+ $fileinfo = new SplFileInfo($templateDirectory . $v);
+ if ($fileinfo->getExtension() == 'html' && $fileinfo->getFilename() != 'index.html') {
+ @unlink($templateDirectory . $v);
+ }
+ }
+ // Load class XoopsFile
+ xoops_load('xoopsfile');
+ //delete /images directory
+ $imagesDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/images/";
+ $folderHandler = XoopsFile::getHandler("folder", $imagesDirectory);
+ $folderHandler->delete($imagesDirectory);
+ //delete /css directory
+ $cssDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/css/";
+ $folderHandler = XoopsFile::getHandler("folder", $cssDirectory);
+ $folderHandler->delete($cssDirectory);
+ //delete /js directory
+ $jsDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/js/";
+ $folderHandler = XoopsFile::getHandler("folder", $jsDirectory);
+ $folderHandler->delete($jsDirectory);
+ //delete /tcpdf directory
+ $tcpdfDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/tcpdf/";
+ $folderHandler = XoopsFile::getHandler("folder", $tcpdfDirectory);
+ $folderHandler->delete($tcpdfDirectory);
+ //delete /templates/style.css file
+// $cssFile = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/templates/style.css";
+// $folderHandler = XoopsFile::getHandler("file", $cssFile);
+// $folderHandler->delete($cssFile);
+ }
+
$gperm_handler = xoops_gethandler('groupperm');
-
return $gperm_handler->deleteByModule($module->getVar('mid'), "item_read");
}
+
|