3 namespace wcf\system\event\listener
;
5 use wcf\acp\form\UserGroupAddForm
;
6 use wcf\acp\form\UserGroupEditForm
;
7 use wcf\data\user\group\UserGroup
;
11 * Handles 'canBeAddedAsConversationParticipant' setting.
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\Event\Listener
18 class UserGroupAddCanBeAddedAsConversationParticipantListener
implements IParameterizedEventListener
21 * instance of UserGroupAddForm
22 * @var UserGroupAddForm|UserGroupEditForm
27 * true if group can be added as participant
30 protected $canBeAddedAsConversationParticipant = 0;
35 public function execute($eventObj, $className, $eventName, array &$parameters)
37 $this->eventObj
= $eventObj;
39 if ($this->eventObj
instanceof UserGroupEditForm
&& \
is_object($this->eventObj
->group
)) {
40 switch ($this->eventObj
->group
->groupType
) {
41 case UserGroup
::EVERYONE
:
42 case UserGroup
::GUESTS
:
43 case UserGroup
::USERS
:
48 $this->{$eventName}();
52 * Handles the assignVariables event.
54 protected function assignVariables()
56 WCF
::getTPL()->assign([
57 'canBeAddedAsConversationParticipant' => $this->canBeAddedAsConversationParticipant
,
62 * Handles the readData event.
63 * This is only called in UserGroupEditForm.
65 protected function readData()
68 $this->canBeAddedAsConversationParticipant
= $this->eventObj
->group
->canBeAddedAsConversationParticipant
;
73 * Handles the readFormParameters event.
75 protected function readFormParameters()
77 if (isset($_POST['canBeAddedAsConversationParticipant'])) {
78 $this->canBeAddedAsConversationParticipant
= \
intval($_POST['canBeAddedAsConversationParticipant']);
83 * Handles the save event.
85 protected function save()
87 $this->eventObj
->additionalFields
= \array_merge
($this->eventObj
->additionalFields
, [
88 'canBeAddedAsConversationParticipant' => $this->canBeAddedAsConversationParticipant
,