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
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @package XoopsModules\Pedigree |
14
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
15
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author XOOPS Development Team |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use \Xmf\Database\Tables; |
20
|
|
|
use XoopsModules\Pedigree\{ |
21
|
|
|
Utility |
22
|
|
|
}; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Make updates to module tables, files, configs, etc. during module update |
26
|
|
|
* |
27
|
|
|
* @param \XoopsModule $module |
28
|
|
|
* @param string $prev_ver |
29
|
|
|
* |
30
|
|
|
* @return bool |
31
|
|
|
*/ |
32
|
|
|
|
33
|
|
|
function xoops_module_update_pedigree(\XoopsModule $module, string $prev_ver) |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* {@internal Both success and failure messages can be sent back to the calling |
37
|
|
|
* routine via the $module->setErrors() method. }} |
38
|
|
|
*/ |
39
|
|
|
|
40
|
|
|
$tableMap = [ |
41
|
|
|
//from tablename => to tablename |
42
|
|
|
['from' => 'owner', 'to' => 'pedigree_owner'], |
43
|
|
|
['from' => 'stamboom', 'to' => 'pedigree_registry'], |
44
|
|
|
['from' => 'pedigree_config', 'to' => 'pedigree_fields'], |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
$success = true; |
48
|
|
|
|
49
|
|
|
$tables = new Tables(); |
50
|
|
|
foreach ($tableMap as $map) { |
51
|
|
|
$success = $success && $tables->renameTable($map['from'], $map['to']); |
52
|
|
|
/** @TODO move hard coded language string to language file */ |
53
|
|
|
$msg = $success ? sprintf('Successfully renamed %s table', $map['to']) : sprintf('Failed to rename table %s to %s', $map['from'], $map['to']); |
54
|
|
|
$module->setErrors($msg); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $success; |
58
|
|
|
} |
59
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.