From cca12eee3666dee40cc3fc97b3b98bada88e2db4 Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Mon, 22 May 2006 11:32:46 +0000 Subject: [PATCH] KTS-961: Allow administrators to make it possible to only email people in your own group. --- config/config.ini | 3 +++ plugins/ktstandard/KTEmail.php | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config/config.ini b/config/config.ini index 8caffac..7f6d3e2 100644 --- a/config/config.ini +++ b/config/config.ini @@ -123,6 +123,9 @@ allowEmailAddresses = default ; Set to true to always send email from the emailFrom address listed ; above, even if there is an identifiable sending user sendAsSystem = default +; Set to true to only allow users to send emails to those in the same +; groups as them +onlyOwnGroups = default [urls] ; directories diff --git a/plugins/ktstandard/KTEmail.php b/plugins/ktstandard/KTEmail.php index 16a74da..1e60018 100644 --- a/plugins/ktstandard/KTEmail.php +++ b/plugins/ktstandard/KTEmail.php @@ -263,8 +263,29 @@ class KTDocumentEmailAction extends KTDocumentAction { $fields[] = new KTTextWidget(_kt("Email addresses"), _kt("Add extra email addresses here"), 'fEmailAddresses', "", $this->oPage, false, null, null, array('cols' => 60, 'rows' => 5)); } $fields[] = new KTTextWidget(_kt("Comment"), _kt("A message for those who receive the document"), 'fComment', "", $this->oPage, true, null, null, array('cols' => 60, 'rows' => 5)); - $aGroups = Group::getList(); - $aUsers = User::getEmailUsers(); + + $oKTConfig =& KTConfig::getSingleton(); + $bOnlyOwnGroup = $oKTConfig->get('email/onlyOwnGroup', false); + if ($bOnlyOwnGroup != true) { + $aGroups = Group::getList(); + $aUsers = User::getEmailUsers(); + } else { + $aGroups = GroupUtil::listGroupsForUser($this->oUser); + $aMembers = array(); + foreach ($aGroups as $oGroup) { + $aMembers = array_merge($aMembers, $oGroup->getMembers()); + } + $aUsers = array(); + $aUserIds = array(); + foreach ($aMembers as $oUser) { + if (in_array($oUser->getId(), $aUserIds)) { + continue; + } + $aUsers[] = $oUser; + $aUserIds[] = $oUser->getId(); + } + } + $aTemplateData = array( 'context' => &$this, 'fields' => $fields, -- libgit2 0.21.4