Commit cca12eee3666dee40cc3fc97b3b98bada88e2db4

Authored by Neil Blakey-Milner
1 parent 65edf33c

KTS-961: Allow administrators to make it possible to only email people

in your own group.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5419 c91229c3-7414-0410-bfa2-8a42b809f60b
config/config.ini
... ... @@ -123,6 +123,9 @@ allowEmailAddresses = default
123 123 ; Set to true to always send email from the emailFrom address listed
124 124 ; above, even if there is an identifiable sending user
125 125 sendAsSystem = default
  126 +; Set to true to only allow users to send emails to those in the same
  127 +; groups as them
  128 +onlyOwnGroups = default
126 129  
127 130 [urls]
128 131 ; directories
... ...
plugins/ktstandard/KTEmail.php
... ... @@ -263,8 +263,29 @@ class KTDocumentEmailAction extends KTDocumentAction {
263 263 $fields[] = new KTTextWidget(_kt("Email addresses"), _kt("Add extra email addresses here"), 'fEmailAddresses', "", $this->oPage, false, null, null, array('cols' => 60, 'rows' => 5));
264 264 }
265 265 $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));
266   - $aGroups = Group::getList();
267   - $aUsers = User::getEmailUsers();
  266 +
  267 + $oKTConfig =& KTConfig::getSingleton();
  268 + $bOnlyOwnGroup = $oKTConfig->get('email/onlyOwnGroup', false);
  269 + if ($bOnlyOwnGroup != true) {
  270 + $aGroups = Group::getList();
  271 + $aUsers = User::getEmailUsers();
  272 + } else {
  273 + $aGroups = GroupUtil::listGroupsForUser($this->oUser);
  274 + $aMembers = array();
  275 + foreach ($aGroups as $oGroup) {
  276 + $aMembers = array_merge($aMembers, $oGroup->getMembers());
  277 + }
  278 + $aUsers = array();
  279 + $aUserIds = array();
  280 + foreach ($aMembers as $oUser) {
  281 + if (in_array($oUser->getId(), $aUserIds)) {
  282 + continue;
  283 + }
  284 + $aUsers[] = $oUser;
  285 + $aUserIds[] = $oUser->getId();
  286 + }
  287 + }
  288 +
268 289 $aTemplateData = array(
269 290 'context' => &$this,
270 291 'fields' => $fields,
... ...