NobuNobu
nobun****@users*****
2006年 5月 22日 (月) 15:28:50 JST
Index: xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php:1.1.2.6 xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php:1.1.2.7 --- xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php:1.1.2.6 Mon May 22 14:20:04 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleUpdater.class.php Mon May 22 15:28:50 2006 @@ -97,18 +97,23 @@ $blockHandler =& xoops_gethandler('block'); $func_num=0; - foreach ($definedBlocks as $block) { - $func_num++; + $showfuncs = array(); + $funcfiles = array(); + for ($i=1; $i<= count($definedBlocks); $i++) { + $block =& $definedBlocks[$i]; + $func_num = $i; + $showfuncs[]=$block['show_func']; + $funcfiles[]=$block['file']; $newBlock =& Legacy_ModuleUtils::createBlockByInfo($this->mModule, $block); - // // Get a installed block by mid and name. // $criteria = new CriteriaCompo(); $criteria->add(new Criteria('mid', $this->mModule->getVar('mid'))); - $criteria->add(new Criteria('name', $block['name'])); + $criteria->add(new Criteria('func_num', $func_num)); + $criteria->add(new Criteria('show_func', $block['show_func'])); + $criteria->add(new Criteria('func_file', $block['file'])); $installedBlocks =& $blockHandler->getObjectsDirectly($criteria); - // // If a installed block is not found, push it to new install block list. // @@ -137,32 +142,24 @@ unset($newBlock); unset($oldBlock); } - $criteria = new CriteriaCompo(); $criteria->add(new Criteria('mid', $this->mModule->getVar('mid'))); $installedBlocks =& $blockHandler->getObjectsDirectly($criteria); foreach ($installedBlocks as $blockObj) { - $name = $blockObj->getVar('name'); - $findFlag = false; - foreach ($definedBlocks as $definedBlock) { - $findFlag |= ($definedBlock['name'] == $blockObj->getVar('name')); - } - - if (!$findFlag) { + if (!in_array($blockObj->getVar('show_func'), $showfuncs) || !in_array($blockObj->getVar('func_file'), $funcfiles)) { $unInstallBlocks[] =& $blockObj; unset($blockObj); - } - } + } + } foreach ($installBlocks as $block) { Legacy_ModuleUtils::installBlock($this->mModule, $block[0], $block[1], $this->mLog); } - - /* + foreach ($unInstallBlocks as $block) { - Legacy_ModuleUtils::unInstallBlock($block); + Legacy_ModuleUtils::unInstallBlock($block, $this->mLog); } - */ + } function _installPreference() Index: xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.16 xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.17 --- xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.16 Sun Apr 23 00:57:24 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php Mon May 22 15:28:50 2006 @@ -317,6 +317,21 @@ } } + function unInstallBlock(&$block, &$log) { + $blockHandler =& xoops_gethandler('block'); + $blockHandler->delete($block); + $log->addReport("Uninstall block '".$block->getVar('name')); + // + // delete permission + // + $gpermHandler =& xoops_gethandler('groupperm'); + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('gperm_name', 'block_read')); + $criteria->add(new Criteria('gperm_itemid', $block->getVar('bid'))); + $criteria->add(new Criteria('gperm_modid', 1)); + $gpermHandler->deleteAll($criteria); + } + /** * Save the information of block's template specified and the source code of it * to database.