action = $action; $userGroups = Repo::userGroup()->getCollector() ->filterByContextIds([$context->getId()]) ->getMany(); $userCountByGroupId = Repo::userGroup()->getUserCountByContextId($context->getId()); $userGroupOptions = []; foreach ($userGroups as $userGroup) { if (in_array($userGroup->getId(), (array) $context->getData('disableBulkEmailUserGroups'))) { continue; } $userGroupOptions[] = [ 'value' => $userGroup->getId(), 'label' => $userGroup->getLocalizedData('name'), ]; $this->userGroupCounts[$userGroup->getId()] = $userCountByGroupId->get($userGroup->getId(), 0); } $currentUser = Application::get()->getRequest()->getUser(); $this->addField(new FieldOptions('userGroupIds', [ 'label' => __('user.roles'), 'description' => __('manager.setup.notifyUsers.description'), 'value' => [], 'options' => $userGroupOptions, 'required' => true, ])) ->addField(new FieldText('subject', [ 'label' => __('email.subject'), 'value' => '', 'required' => true, ])) ->addField(new FieldRichTextarea('body', [ 'label' => __('email.email'), 'size' => 'large', 'value' => '', 'required' => true, ])) ->addField(new FieldOptions('copy', [ 'label' => __('common.copy'), 'value' => 0, 'options' => [ [ 'value' => 1, 'label' => __('manager.setup.notifyUsers.copyDetails', ['email' => $currentUser->getEmail()]), ], ] ])); } /** * @copydoc FormComponent::getConfig() */ public function getConfig() { $config = parent::getConfig(); $config['confirmLabel'] = __('manager.setup.notifyUsers.confirm'); $config['sendLabel'] = __('manager.setup.notifyUsers.send'); $config['userGroupCounts'] = $this->userGroupCounts; return $config; } }