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:
15: 16: 17: 18: 19: 20: 21: 22: 23:
24:
25: function b_system_topposters_show($options)
26: {
27: $xoops = Xoops::getInstance();
28: $block = array();
29: $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
30: $limit = (!empty($options[0])) ? $options[0] : 10;
31: $size = count($options);
32: for ($i = 2; $i < $size; ++$i) {
33: $criteria->add(new Criteria('rank', $options[$i], '<>'));
34: }
35: $criteria->setOrder('DESC');
36: $criteria->setSort('posts');
37: $criteria->setLimit($limit);
38: $member_handler = $xoops->getHandlerMember();
39: $topposters = $member_handler->getUsers($criteria);
40: $count = count($topposters);
41: for ($i = 0; $i < $count; ++$i) {
42: $block['users'][$i]['rank'] = $i + 1;
43: if ($options[1] == 1) {
44: $block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') !== 'blank.gif' ? \XoopsBaseConfig::get('uploads-url') . '/' . $topposters[$i]->getVar('user_avatar') : '';
45: } else {
46: $block['users'][$i]['avatar'] = '';
47: }
48: $block['users'][$i]['id'] = $topposters[$i]->getVar('uid');
49: $block['users'][$i]['name'] = $topposters[$i]->getVar('uname');
50: $block['users'][$i]['posts'] = $topposters[$i]->getVar('posts');
51: }
52: return $block;
53: }
54:
55: function b_system_topposters_edit($options)
56: {
57: $block_form = new Xoops\Form\BlockForm();
58: $block_form->addElement(new Xoops\Form\Text(SystemLocale::NUMBER_OF_USERS_TO_DISPLAY, 'options[0]', 1, 3, $options[0]), true);
59: $block_form->addElement(new Xoops\Form\RadioYesNo(SystemLocale::DISPLAY_USERS_AVATARS, 'options[1]', $options[1]));
60:
61: $xoops = \Xoops::getInstance();
62: $ranks = $xoops->service('userrank')->getAssignableUserRankList()->getValue();
63: if ($ranks === null) {
64: $ranks = [];
65: }
66: $ranks_select = new Xoops\Form\Select(SystemLocale::C_DO_NOT_DISPLAY_USERS_WHOSE_RANK_IS, 'options[2]', explode(',', $options[2]), 5, true);
67: $ranks_select->addOptionArray($ranks);
68: $block_form->addElement($ranks_select);
69: return $block_form->render();
70: }
71: