2 namespace wcf\system\event\listener
;
3 use wcf\acp\form\UserGroupAddForm
;
4 use wcf\acp\form\UserGroupEditForm
;
5 use wcf\data\user\group\UserGroup
;
9 * Handles 'canBeAddedAsConversationParticipant' setting.
12 * @copyright 2001-2019 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\System\Event\Listener
16 class UserGroupAddCanBeAddedAsConversationParticipantListener
implements IParameterizedEventListener
{
18 * instance of UserGroupAddForm
19 * @var UserGroupAddForm|UserGroupEditForm
24 * true if group can be added as participant
27 protected $canBeAddedAsConversationParticipant = 0;
32 public function execute($eventObj, $className, $eventName, array &$parameters) {
33 $this->eventObj
= $eventObj;
35 if ($this->eventObj
instanceof UserGroupEditForm
&& is_object($this->eventObj
->group
)) {
36 switch ($this->eventObj
->group
->groupType
) {
37 case UserGroup
::EVERYONE
:
38 case UserGroup
::GUESTS
:
39 case UserGroup
::USERS
:
48 * Handles the assignVariables event.
50 protected function assignVariables() {
51 WCF
::getTPL()->assign([
52 'canBeAddedAsConversationParticipant' => $this->canBeAddedAsConversationParticipant
57 * Handles the readData event.
58 * This is only called in UserGroupEditForm.
60 protected function readData() {
62 $this->canBeAddedAsConversationParticipant
= $this->eventObj
->group
->canBeAddedAsConversationParticipant
;
67 * Handles the readFormParameters event.
69 protected function readFormParameters() {
70 if (isset($_POST['canBeAddedAsConversationParticipant'])) $this->canBeAddedAsConversationParticipant
= intval($_POST['canBeAddedAsConversationParticipant']);
74 * Handles the save event.
76 protected function save() {
77 $this->eventObj
->additionalFields
= array_merge($this->eventObj
->additionalFields
, [
78 'canBeAddedAsConversationParticipant' => $this->canBeAddedAsConversationParticipant