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: namespace Xoops\Form;
13:
14: use Xoops\Core\Kernel\Criteria;
15: use Xoops\Core\FixedGroups;
16:
17: /**
18: * SelectGroup - a select field with a choice of available groups
19: *
20: * @category Xoops\Form\SelectGroup
21: * @package Xoops\Form
22: * @author Kazumi Ono <onokazu@xoops.org>
23: * @copyright 2001-2015 XOOPS Project (http://xoops.org)
24: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
25: * @link http://xoops.org
26: */
27: class SelectGroup extends Select
28: {
29: /**
30: * Constructor
31: *
32: * @param string|array $caption Caption or array of all attributes
33: * Control attributes:
34: * :include_anon true to include anonymous groups
35: * @param string $name element name
36: * @param boolean $include_anon Include group "anonymous"?
37: * @param mixed $value Pre-selected value (or array of them).
38: * @param integer $size Number or rows. "1" makes a drop-down-list.
39: * @param boolean $multiple Allow multiple selections?
40: */
41: public function __construct($caption, $name = null, $include_anon = false, $value = null, $size = 1, $multiple = false)
42: {
43: parent::__construct($caption, $name, $value, $size, $multiple);
44: $member_handler = \Xoops::getInstance()->getHandlerMember();
45: if ($include_anon || $this->get(':include_anon', false)) {
46: $this->addOptionArray($member_handler->getGroupList());
47: } else {
48: $this->addOptionArray($member_handler->getGroupList(new Criteria('groupid', FixedGroups::ANONYMOUS, '!=')));
49: }
50: }
51: }
52: