1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\FixedGroups;
13: use Xoops\Core\Kernel\Handlers\XoopsModule;
14: use Xmf\Database\TableLoad;
15:
16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: function xoops_module_install_system(XoopsModule $module)
35: {
36: $xoops = Xoops::getInstance();
37:
38:
39: $rows = array(
40: array(
41: 'groupid' => FixedGroups::ADMIN,
42: 'name' => SystemLocale::WEBMASTERS,
43: 'description' => SystemLocale::WEBMASTERS_OF_THIS_SITE,
44: 'group_type' => 'Admin',
45: ),
46: array(
47: 'groupid' => FixedGroups::USERS,
48: 'name' => SystemLocale::REGISTERED_USERS,
49: 'description' => SystemLocale::REGISTERED_USERS_GROUP,
50: 'group_type' => 'Admin',
51: ),
52: array(
53: 'groupid' => FixedGroups::ANONYMOUS,
54: 'name' => SystemLocale::ANONYMOUS_USERS,
55: 'description' => SystemLocale::ANONYMOUS_USERS_GROUP,
56: 'group_type' => 'Admin',
57: ),
58: array(
59: 'groupid' => FixedGroups::REMOVED,
60: 'name' => SystemLocale::REMOVED_USERS,
61: 'description' => SystemLocale::REMOVED_USERS_GROUP,
62: 'group_type' => 'Removed',
63: ),
64: );
65: TableLoad::loadTableFromArray('system_group', $rows);
66:
67:
68: $groupperm_handler = $xoops->getHandlerGroupPermission();
69: $allGroups = array(FixedGroups::USERS, FixedGroups::ANONYMOUS);
70: foreach ($allGroups as $gid) {
71: $obj = $groupperm_handler->create();
72: $obj->setVar("gperm_groupid", $gid);
73: $obj->setVar("gperm_itemid", '1');
74: $obj->setVar("gperm_modid", '1');
75: $obj->setVar("gperm_name", 'module_read');
76: if (!$groupperm_handler->insert($obj)) {
77: echo $xoops->alert('error', $obj->getHtmlErrors());
78: }
79: }
80:
81:
82: $blockmodulelink_handler = $xoops->getHandlerBlockModuleLink();
83: $block_handler = $xoops->getHandlerBlock();
84: $blocks = $block_handler->getByModule(1);
85: foreach ($blocks as $block) {
86: if (in_array($block->getVar('template'), array(
87: 'system_block_user.tpl',
88: 'system_block_login.tpl',
89: 'system_block_mainmenu.tpl'
90: ))
91: ) {
92: $block->setVar('visible', 1);
93: $block_handler->insert($block, true);
94:
95: $blockmodulelink = $blockmodulelink_handler->create();
96: $blockmodulelink->setVar('block_id', $block->getVar('bid'));
97: $blockmodulelink->setVar('module_id', 0);
98: $blockmodulelink_handler->insert($blockmodulelink);
99:
100: for ($i = 2; $i <= 3; ++$i) {
101: $obj = $groupperm_handler->create();
102: $obj->setVar("gperm_groupid", $i);
103: $obj->setVar("gperm_itemid", $block->id());
104: $obj->setVar("gperm_modid", '1');
105: $obj->setVar("gperm_name", 'block_read');
106: if (!$groupperm_handler->insert($obj)) {
107: echo $xoops->alert('error', $obj->getHtmlErrors());
108: }
109: }
110: }
111: }
112:
113: $tplset_handler = $xoops->getHandlerTplSet();
114: $obj = $tplset_handler->create();
115: $obj->setVar("tplset_name", 'default');
116: $obj->setVar("tplset_desc", 'XOOPS Default Template Set');
117: $obj->setVar("tplset_credits", '');
118: $obj->setVar("tplset_created", time());
119: if (!$tplset_handler->insert($obj)) {
120: echo $xoops->alert('error', $obj->getHtmlErrors());
121: }
122:
123:
124:
125: $types = array(\PDO::PARAM_INT, \PDO::PARAM_INT);
126: $data = array('groupid' => FixedGroups::ADMIN, 'uid' => 1);
127: $xoops->db()->insertPrefix('system_usergroup', $data, $types);
128: $data = array('groupid' => FixedGroups::USERS, 'uid' => 1);
129: $xoops->db()->insertPrefix('system_usergroup', $data, $types);
130: }
131: