1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Kernel\Criteria;
13: use Xoops\Core\Kernel\CriteriaCompo;
14: use Xoops\Core\Kernel\Handlers\XoopsModule;
15:
16: 17: 18: 19: 20: 21: 22: 23: 24:
25:
26: 27: 28: 29: 30: 31: 32:
33: function xoops_module_update_system(XoopsModule $module)
34: {
35: $xoops = Xoops::getInstance();
36: if ($module->getVar('version') == 100) {
37: $qb = $xoops->db()->createXoopsQueryBuilder();
38: $eb = $qb->expr();
39: $sql = $qb->select('t1.tpl_id')
40: ->fromPrefix('system_tplfile', 't1')
41: ->fromPrefix('system_tplfile', 't2')
42: ->where($eb->eq('t1.tpl_module', 't2.tpl_module '))
43: ->andWhere($eb->eq('t1.tpl_tplset', 't2.tpl_tplset'))
44: ->andWhere($eb->eq('t1.tpl_file', 't2.tpl_file'))
45: ->andWhere($eb->eq('t1.tpl_id', 't2.tpl_id'));
46: $result = $sql->execute();
47: $tplids = array();
48: while (list($tplid) = $result->fetch(PDO::FETCH_NUM)) {
49: $tplids[] = $tplid;
50: }
51: if (count($tplids) > 0) {
52: $tplfile_handler = $xoops->getHandlerTplFile();
53: $duplicate_files = $tplfile_handler->getTplObjects(
54: new Criteria('tpl_id', "(".implode(',', $tplids).")", "IN")
55: );
56:
57: if (count($duplicate_files) > 0) {
58: foreach (array_keys($duplicate_files) as $i) {
59: $tplfile_handler->deleteTpl($duplicate_files[$i]);
60: }
61: }
62: }
63: }
64:
65:
66:
67: $config_handler = $xoops->getHandlerConfig();
68: $criteria = new CriteriaCompo();
69: $criteria->add(new Criteria('conf_modid', 0));
70: $criteria->add(new Criteria('conf_catid', 5, '!='));
71: $criteria->add(new Criteria('conf_catid', 6, '!='));
72: $configs = $config_handler->getConfigs($criteria);
73: $confcount = count($configs);
74: if ($confcount > 0) {
75: for ($i = 0; $i < $confcount; ++$i) {
76: $criteria = new CriteriaCompo();
77: $criteria->add(new Criteria('conf_modid', 1));
78: $criteria->add(new Criteria('conf_name', $configs[$i]->getVar('conf_name')));
79: $new_configs = $config_handler->getConfigs($criteria);
80: $new_confcount = count($new_configs);
81: if ($new_confcount > 0) {
82: for ($j = 0; $j < $new_confcount; ++$j) {
83: $obj = $config_handler->getConfig($new_configs[$j]->getVar('conf_id'));
84: }
85: $obj->setVar("conf_value", $configs[$i]->getVar('conf_value'));
86: $config_handler->insertConfig($obj);
87: $config_handler->deleteConfig($configs[$i]);
88: }
89:
90: }
91:
92: }
93: return true;
94: }
95: