XOOPS  2.6.0
update.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
14 
33 {
35  if ($module->getVar('version') == 100) {
36  $qb = $xoops->db()->createXoopsQueryBuilder();
37  $eb = $qb->expr();
38  $sql = $qb->select('t1.tpl_id')
39  ->fromPrefix('tplfile', 't1')
40  ->fromPrefix('tplfile', 't2')
41  ->where($eb->eq('t1.tpl_module', 't2.tpl_module '))
42  ->andWhere($eb->eq('t1.tpl_tplset', 't2.tpl_tplset'))
43  ->andWhere($eb->eq('t1.tpl_file', 't2.tpl_file'))
44  ->andWhere($eb->eq('t1.tpl_id', 't2.tpl_id'));
45  $result = $sql->execute();
46  $tplids = array();
47  while (list($tplid) = $result->fetch(PDO::FETCH_NUM)) {
48  $tplids[] = $tplid;
49  }
50  if (count($tplids) > 0) {
51  $tplfile_handler = $xoops->getHandlerTplfile();
52  $duplicate_files = $tplfile_handler->getTplObjects(
53  new Criteria('tpl_id', "(".implode(',', $tplids).")", "IN")
54  );
55 
56  if (count($duplicate_files) > 0) {
57  foreach (array_keys($duplicate_files) as $i) {
58  $tplfile_handler->deleteTpl($duplicate_files[$i]);
59  }
60  }
61  }
62  }
63  // Copy old configs in new configs and delete old configs
64  // Not for conf_catid =5 (Update in search extension)
65  // Not for conf_catid =6 (Update in mail user extension)
66  $config_handler = $xoops->getHandlerConfig();
67  $criteria = new CriteriaCompo();
68  $criteria->add(new Criteria('conf_modid', 0));
69  $criteria->add(new Criteria('conf_catid', 5, '!='));
70  $criteria->add(new Criteria('conf_catid', 6, '!='));
71  $configs = $config_handler->getConfigs($criteria);
72  $confcount = count($configs);
73  if ($confcount > 0) {
74  for ($i = 0; $i < $confcount; ++$i) {
75  $criteria = new CriteriaCompo();
76  $criteria->add(new Criteria('conf_modid', 1));
77  $criteria->add(new Criteria('conf_name', $configs[$i]->getvar('conf_name')));
78  $new_configs = $config_handler->getConfigs($criteria);
79  $new_confcount = count($new_configs);
80  if ($new_confcount > 0) {
81  for ($j = 0; $j < $new_confcount; ++$j) {
82  $obj = $config_handler->getConfig($new_configs[$j]->getvar('conf_id'));
83  }
84  $obj->setVar("conf_value", $configs[$i]->getvar('conf_value'));
85  $config_handler->insertConfig($obj);
86  $config_handler->deleteConfig($configs[$i]);
87  }
88 
89  }
90 
91  }
92  return true;
93 }
$i
Definition: dialog.php:68
static getInstance()
Definition: Xoops.php:160
$result
Definition: pda.php:33
getVar($key, $format= 's')
$module
Definition: update.php:55
if($_SERVER['REQUEST_METHOD']== 'POST') $config_handler
$configs
Definition: config.php:27
$sql
Definition: pda.php:32
$criteria
$duplicate_files
Definition: config.php:127
xoops_module_update_system(XoopsModule &$module)
Definition: update.php:32
$j
Definition: help.php:169
$xoops
Definition: update.php:23