1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Yaml;
13:
14: 15: 16: 17: 18:
19:
20: function xoops_module_install_userrank($module)
21: {
22: $xoops = Xoops::getInstance();
23: $xoops->header();
24: $lang_rank_titles = array(
25: 'dummy',
26: _MI_RANK_TITLE_1,
27: _MI_RANK_TITLE_2,
28: _MI_RANK_TITLE_3,
29: _MI_RANK_TITLE_4,
30: _MI_RANK_TITLE_5,
31: _MI_RANK_TITLE_6,
32: _MI_RANK_TITLE_7,
33: );
34: $filedata = <<<EOT
35: -
36: rank_id: 1
37: rank_title: "{$lang_rank_titles[1]}"
38: rank_min: 0
39: rank_max: 20
40: rank_special: 0
41: rank_image: "ranks/rank3e632f95e81ca.gif"
42: -
43: rank_id: 2
44: rank_title: "{$lang_rank_titles[2]}"
45: rank_min: 21
46: rank_max: 40
47: rank_special: 0
48: rank_image: "ranks/rank3dbf8e94a6f72.gif"
49: -
50: rank_id: 3
51: rank_title: "{$lang_rank_titles[3]}"
52: rank_min: 41
53: rank_max: 70
54: rank_special: 0
55: rank_image: "ranks/rank3dbf8e9e7d88d.gif"
56: -
57: rank_id: 4
58: rank_title: "{$lang_rank_titles[4]}"
59: rank_min: 71
60: rank_max: 150
61: rank_special: 0
62: rank_image: "ranks/rank3dbf8ea81e642.gif"
63: -
64: rank_id: 5
65: rank_title: "{$lang_rank_titles[5]}"
66: rank_min: 151
67: rank_max: 10000
68: rank_special: 0
69: rank_image: "ranks/rank3dbf8eb1a72e7.gif"
70: -
71: rank_id: 6
72: rank_title: "{$lang_rank_titles[6]}"
73: rank_min: 0
74: rank_max: 0
75: rank_special: 1
76: rank_image: "ranks/rank3dbf8edf15093.gif"
77: -
78: rank_id: 7
79: rank_title: "{$lang_rank_titles[7]}"
80: rank_min: 0
81: rank_max: 0
82: rank_special: 1
83: rank_image: "ranks/rank3dbf8ee8681cd.gif"
84: EOT;
85:
86: $tablerows = Yaml::load($filedata);
87:
88: $dbm = $xoops->db();
89: $count = $dbm->fetchColumn('SELECT COUNT(*) FROM ' . $dbm->prefix('userrank_rank'));
90: if ($count<1) {
91: $dbm->beginTransaction();
92: foreach ($tablerows as $row) {
93: $dbm->insertPrefix('userrank_rank', $row);
94: }
95: $dbm->commit();
96: }
97: return true;
98: }
99: