| 1 |
<?php |
| 2 |
|
| 3 |
use LAM\PDF\PDFTable; |
| 4 |
use LAM\PDF\PDFTableCell; |
| 5 |
use LAM\PDF\PDFTableRow; |
| 6 |
use LAM\TYPES\ConfiguredType; |
| 7 |
|
| 8 |
/* |
| 9 |
|
| 10 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 11 |
Copyright (C) 2004 - 2026 Roland Gruber |
| 12 |
|
| 13 |
This program is free software; you can redistribute it and/or modify |
| 14 |
it under the terms of the GNU General Public License as published by |
| 15 |
the Free Software Foundation; either version 2 of the License, or |
| 16 |
(at your option) any later version. |
| 17 |
|
| 18 |
This program is distributed in the hope that it will be useful, |
| 19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
GNU General Public License for more details. |
| 22 |
|
| 23 |
You should have received a copy of the GNU General Public License |
| 24 |
along with this program; if not, write to the Free Software |
| 25 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 26 |
*/ |
| 27 |
|
| 28 |
/** |
| 29 |
* Manages Kolab user accounts. |
| 30 |
* |
| 31 |
* @package modules |
| 32 |
* @author Roland Gruber |
| 33 |
*/ |
| 34 |
|
| 35 |
/** |
| 36 |
* Manages Kolab user accounts. |
| 37 |
* |
| 38 |
* @package modules |
| 39 |
*/ |
| 40 |
class kolabUser extends baseModule { |
| 41 |
|
| 42 |
/** @var array<string, string> $invitationPolicies list of invitation policies */ |
| 43 |
private array $invitationPolicies; |
| 44 |
|
| 45 |
/** |
| 46 |
* Creates a new kolabUser object. |
| 47 |
* |
| 48 |
* @param string $scope account type (user, group, host) |
| 49 |
*/ |
| 50 |
public function __construct($scope) { |
| 51 |
// call parent constructor |
| 52 |
parent::__construct($scope); |
| 53 |
// list of invitation policies |
| 54 |
$this->invitationPolicies = [ |
| 55 |
'ACT_ALWAYS_ACCEPT' => _('Always accept'), |
| 56 |
'ACT_ALWAYS_REJECT' => _('Always reject'), |
| 57 |
'ACT_MANUAL' => _('Manual'), |
| 58 |
'ACT_REJECT_IF_CONFLICTS' => _('Reject if conflicts'), |
| 59 |
'ACT_MANUAL_IF_CONFLICTS' => _('Manual if conflicts') |
| 60 |
]; |
| 61 |
$this->autoAddObjectClasses = false; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* {@inheritDoc} |
| 66 |
*/ |
| 67 |
public function can_manage(): bool { |
| 68 |
return $this->get_scope() === 'user'; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* {@inheritDoc} |
| 73 |
*/ |
| 74 |
public function get_metaData(): array { |
| 75 |
$return = []; |
| 76 |
// icon |
| 77 |
$return['icon'] = 'kolab.png'; |
| 78 |
// alias name |
| 79 |
$return["alias"] = _("Kolab"); |
| 80 |
// module dependencies |
| 81 |
$return['dependencies'] = ['depends' => ['inetOrgPerson'], 'conflicts' => []]; |
| 82 |
// LDAP filter |
| 83 |
$return["ldap_filter"] = ['or' => "(objectClass=kolabInetOrgPerson)"]; |
| 84 |
// managed object classes |
| 85 |
$return['objectClasses'] = ['kolabInetOrgPerson', 'mailrecipient']; |
| 86 |
// managed attributes |
| 87 |
$return['attributes'] = ['alias', 'kolabDelegate', 'kolabInvitationPolicy', |
| 88 |
'kolabAllowSMTPRecipient', 'kolabAllowSMTPSender', 'mailQuota']; |
| 89 |
// profile options |
| 90 |
$profileContainer = new htmlResponsiveRow(); |
| 91 |
$profileContainer->add(new htmlResponsiveInputField(_('Mailbox quota'), 'kolab_mailQuota', null, 'mailQuota')); |
| 92 |
$return['profile_options'] = $profileContainer; |
| 93 |
// profile checks |
| 94 |
$return['profile_checks']['kolab_mailQuota'] = [ |
| 95 |
'type' => 'ext_preg', |
| 96 |
'regex' => 'digit', |
| 97 |
'error_message' => $this->messages['mailQuota'][0]]; |
| 98 |
// self-service field settings |
| 99 |
$return['selfServiceFieldSettings'] = [ |
| 100 |
'kolabDelegate' => _('Delegates'), |
| 101 |
'kolabInvitationPolicy' => _('Invitation policy') |
| 102 |
]; |
| 103 |
// possible self-service read-only fields |
| 104 |
$return['selfServiceReadOnlyFields'] = ['kolabDelegate', 'kolabInvitationPolicy']; |
| 105 |
// help Entries |
| 106 |
$return['help'] = [ |
| 107 |
'invPol' => [ |
| 108 |
"Headline" => _("Invitation policy"), 'attr' => 'kolabInvitationPolicy', |
| 109 |
"Text" => _("For automatic invitation handling.") |
| 110 |
], |
| 111 |
'invPolList' => [ |
| 112 |
"Headline" => _("Invitation policy list"), 'attr' => 'kolabInvitationPolicy', |
| 113 |
"Text" => _("This is a comma separated list of invitation policies.") |
| 114 |
], |
| 115 |
'delegate' => [ |
| 116 |
"Headline" => _("Delegates"), 'attr' => 'kolabDelegate', |
| 117 |
"Text" => _("A user may define who is allowed to act on behalf of herself. This property is checked when using the Kolab smtp daemon (Postfix) to send emails.") |
| 118 |
], |
| 119 |
'delegateList' => [ |
| 120 |
"Headline" => _("Delegates"), 'attr' => 'kolabDelegate', |
| 121 |
"Text" => _("This is a semi-colon separated list of delegates.") |
| 122 |
], |
| 123 |
'alias' => [ |
| 124 |
"Headline" => _("Email alias"), 'attr' => 'alias', |
| 125 |
"Text" => _("Email alias for this account.") |
| 126 |
], |
| 127 |
'aliasList' => [ |
| 128 |
"Headline" => _("Email alias list"), 'attr' => 'alias', |
| 129 |
"Text" => _("This is a comma separated list of eMail aliases.") |
| 130 |
], |
| 131 |
'kolabAllowSMTPRecipient' => [ |
| 132 |
"Headline" => _('Allowed recipients'), 'attr' => 'kolabAllowSMTPRecipient', |
| 133 |
"Text" => _('Describes the allowed or disallowed SMTP recipient addresses for mail sent by this account (e.g. "domain.tld" or "[email protected]").') |
| 134 |
], |
| 135 |
'kolabAllowSMTPRecipientList' => [ |
| 136 |
"Headline" => _('Allowed recipients'), 'attr' => 'kolabAllowSMTPRecipient', |
| 137 |
"Text" => _('Describes the allowed or disallowed SMTP recipient addresses for mail sent by this account (e.g. "domain.tld" or "[email protected]").') |
| 138 |
. ' ' . _("Multiple values are separated by semicolon.") |
| 139 |
], |
| 140 |
'kolabAllowSMTPSender' => [ |
| 141 |
"Headline" => _('Allowed senders'), 'attr' => 'kolabAllowSMTPSender', |
| 142 |
"Text" => _('Describes the allowed or disallowed SMTP addresses sending mail to this account (e.g. "domain.tld" or "[email protected]").') |
| 143 |
], |
| 144 |
'kolabAllowSMTPSenderList' => [ |
| 145 |
"Headline" => _('Allowed senders'), 'attr' => 'kolabAllowSMTPSender', |
| 146 |
"Text" => _('Describes the allowed or disallowed SMTP addresses sending mail to this account (e.g. "domain.tld" or "[email protected]").') |
| 147 |
. ' ' . _("Multiple values are separated by semicolon.") |
| 148 |
], |
| 149 |
'mailQuota' => [ |
| 150 |
"Headline" => _('Mailbox quota'), 'attr' => 'mailQuota', |
| 151 |
"Text" => _('The maximum mailbox size in MB.') |
| 152 |
], |
| 153 |
]; |
| 154 |
// upload fields |
| 155 |
$return['upload_columns'] = [ |
| 156 |
[ |
| 157 |
'name' => 'kolabUser_invPol', |
| 158 |
'description' => _('Invitation policy'), |
| 159 |
'help' => 'invPolList', |
| 160 |
'example' => 'user@domain:ACT_ALWAYS_ACCEPT,user2@domain:ACT_MANUAL' |
| 161 |
], |
| 162 |
[ |
| 163 |
'name' => 'kolabUser_mailQuota', |
| 164 |
'description' => _('Mailbox quota'), |
| 165 |
'help' => 'mailQuota', |
| 166 |
'example' => '2000', |
| 167 |
], |
| 168 |
[ |
| 169 |
'name' => 'kolabUser_aliases', |
| 170 |
'description' => _('Email aliases'), |
| 171 |
'help' => 'aliasList', |
| 172 |
'example' => 'user@domain,user2@domain' |
| 173 |
], |
| 174 |
[ |
| 175 |
'name' => 'kolabUser_delegates', |
| 176 |
'description' => _('Delegates'), |
| 177 |
'help' => 'delegateList', |
| 178 |
'example' => 'uid=user,ou=People,dc=example,dc=com;uid=user2,ou=People,dc=example,dc=com' |
| 179 |
], |
| 180 |
[ |
| 181 |
'name' => 'kolabUser_kolabAllowSMTPRecipient', |
| 182 |
'description' => _('Allowed recipients'), |
| 183 |
'help' => 'kolabAllowSMTPRecipientList', |
| 184 |
'example' => '.com; -.net', |
| 185 |
], |
| 186 |
[ |
| 187 |
'name' => 'kolabUser_kolabAllowSMTPSender', |
| 188 |
'description' => _('Allowed senders'), |
| 189 |
'help' => 'kolabAllowSMTPSenderList', |
| 190 |
'example' => '.com; -.net', |
| 191 |
], |
| 192 |
]; |
| 193 |
// available PDF fields |
| 194 |
$return['PDF_fields'] = [ |
| 195 |
'invPol' => _('Invitation policy'), |
| 196 |
'mailQuota' => _('Mailbox quota'), |
| 197 |
'aliases' => _('Email aliases'), |
| 198 |
'delegate' => _('Delegates'), |
| 199 |
'kolabAllowSMTPRecipient' => _('Allowed recipients'), |
| 200 |
'kolabAllowSMTPSender' => _('Allowed senders'), |
| 201 |
]; |
| 202 |
return $return; |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* {@inheritDoc} |
| 207 |
*/ |
| 208 |
protected function load_Messages(): void { |
| 209 |
$this->messages['invPol'][0] = ['ERROR', _('Target of invitation policy is invalid!')]; // third array value is set dynamically |
| 210 |
$this->messages['invPol'][1] = ['ERROR', _('Account %s:') . ' kolabUser_invPol', _('Policy list has invalid format!')]; |
| 211 |
$this->messages['alias'][0] = ['ERROR', _('Email alias is invalid!')]; // third array value is set dynamically |
| 212 |
$this->messages['alias'][1] = ['ERROR', _('Account %s:') . ' kolabUser_aliases', _('Email alias list has invalid format!')]; |
| 213 |
$this->messages['delegate'][0] = ['ERROR', _('Account %s:') . ' kolabUser_delegates', _('Unknown delegate address: %s')]; |
| 214 |
$this->messages['kolabAllowSMTPRecipient'][0] = ['ERROR', _('Allowed recipients'), _('Please enter a valid recipient expression.')]; |
| 215 |
$this->messages['kolabAllowSMTPRecipient'][1] = ['ERROR', _('Account %s:') . ' kolabUser_kolabAllowSMTPRecipient', _('Please enter a valid recipient expression.')]; |
| 216 |
$this->messages['kolabAllowSMTPSender'][0] = ['ERROR', _('Allowed senders'), _('Please enter a valid sender expression.')]; |
| 217 |
$this->messages['kolabAllowSMTPSender'][1] = ['ERROR', _('Account %s:') . ' kolabUser_kolabAllowSMTPSender', _('Please enter a valid sender expression.')]; |
| 218 |
$this->messages['mailQuota'][0] = ['ERROR', _('Mailbox quota'), _('Please enter a number.')]; |
| 219 |
$this->messages['mailQuota'][1] = ['ERROR', _('Account %s:') . ' kolabUser_mailQuota', _('Please enter a number.')]; |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* {@inheritDoc} |
| 224 |
*/ |
| 225 |
public function display_html_attributes(): htmlElement|array { |
| 226 |
$return = new htmlResponsiveRow(); |
| 227 |
if (isset($this->attributes['objectClass']) && in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) { |
| 228 |
$attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); |
| 229 |
if ($this->getAccountContainer()->isNewAccount) { |
| 230 |
if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { |
| 231 |
$attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); |
| 232 |
if (!isset($attrsP['userpassword'][0]) || ($attrsP['userpassword'][0] == '')) { |
| 233 |
$message = new htmlStatusMessage('ERROR', _("Please enter a user password.")); |
| 234 |
$return->add($message); |
| 235 |
} |
| 236 |
} |
| 237 |
elseif (!isset($attrsI['userpassword'][0]) || ($attrsI['userpassword'][0] == '')) { |
| 238 |
$message = new htmlStatusMessage('ERROR', _("Please enter a user password.")); |
| 239 |
$return->add($message); |
| 240 |
} |
| 241 |
} |
| 242 |
if (!isset($attrsI['mail'][0])) { |
| 243 |
$message = new htmlStatusMessage('ERROR', _("Please enter an email address on this page: %s"), '', [$this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias()]); |
| 244 |
$return->add($message); |
| 245 |
} |
| 246 |
// mailbox quota |
| 247 |
$mailQuota = ''; |
| 248 |
if (!empty($this->attributes['mailQuota'][0])) { |
| 249 |
$mailQuota = ((int) $this->attributes['mailQuota'][0]) / 1024; |
| 250 |
} |
| 251 |
$mailQuotaField = new htmlResponsiveInputField(_('Mailbox quota'), 'mailQuota', $mailQuota, 'mailQuota'); |
| 252 |
$mailQuotaField->setMinimumAndMaximumNumber(); |
| 253 |
$return->add($mailQuotaField); |
| 254 |
// invitation policies |
| 255 |
$return->add(new htmlSubTitle(_('Invitation policy'))); |
| 256 |
$invitationContainer = new htmlTable(); |
| 257 |
// default invitation policy |
| 258 |
$defaultInvPol = $this->invitationPolicies['ACT_MANUAL']; |
| 259 |
if (isset($this->attributes['kolabInvitationPolicy'])) { |
| 260 |
for ($i = 0; $i < count($this->attributes['kolabInvitationPolicy']); $i++) { |
| 261 |
$parts = explode(":", $this->attributes['kolabInvitationPolicy'][$i]); |
| 262 |
if (count($parts) === 1) { |
| 263 |
$defaultInvPol = $this->invitationPolicies[$this->attributes['kolabInvitationPolicy'][$i]]; |
| 264 |
unset($this->attributes['kolabInvitationPolicy'][$i]); |
| 265 |
$this->attributes['kolabInvitationPolicy'] = array_values($this->attributes['kolabInvitationPolicy']); |
| 266 |
break; |
| 267 |
} |
| 268 |
} |
| 269 |
} |
| 270 |
$invitationContainer->addElement(new htmlOutputText(_('Anyone'))); |
| 271 |
$invitationContainer->addElement(new htmlSelect('defaultInvPol', array_values($this->invitationPolicies), [$defaultInvPol])); |
| 272 |
$invitationContainer->addElement(new htmlHelpLink('invPol'), true); |
| 273 |
// other invitation policies |
| 274 |
if (isset($this->attributes['kolabInvitationPolicy'])) { |
| 275 |
for ($i = 0; $i < count($this->attributes['kolabInvitationPolicy']); $i++) { |
| 276 |
$parts = explode(":", $this->attributes['kolabInvitationPolicy'][$i]); |
| 277 |
if (count($parts) === 2) { |
| 278 |
$invitationContainer->addElement(new htmlInputField('invPol1' . $i, $parts[0])); |
| 279 |
$invitationContainer->addElement(new htmlSelect('invPol2' . $i, array_values($this->invitationPolicies), [$this->invitationPolicies[$parts[1]]])); |
| 280 |
$invitationContainer->addElement(new htmlButton('delInvPol' . $i, 'del.svg', true)); |
| 281 |
$invitationContainer->addElement(new htmlHelpLink('invPol'), true); |
| 282 |
} |
| 283 |
} |
| 284 |
} |
| 285 |
// input box for new invitation policy |
| 286 |
$invitationContainer->addElement(new htmlInputField('invPol1', '')); |
| 287 |
$invitationContainer->addElement(new htmlSelect('invPol2', array_values($this->invitationPolicies))); |
| 288 |
$invitationContainer->addElement(new htmlButton('addInvPol', 'add.svg', true)); |
| 289 |
$invitationContainer->addElement(new htmlHelpLink('invPol'), true); |
| 290 |
$return->add($invitationContainer); |
| 291 |
// mail aliases |
| 292 |
$return->add(new htmlSubTitle(_('Email aliases'))); |
| 293 |
$this->addMultiValueInputTextField($return, 'alias', null); |
| 294 |
// delegates |
| 295 |
$delegatesData = searchLDAPByAttribute('mail', '*', 'inetOrgPerson', ['dn'], ['user']); |
| 296 |
$delegates = []; |
| 297 |
for ($i = 0; $i < count($delegatesData); $i++) { |
| 298 |
$delegates[getAbstractDN($delegatesData[$i]['dn'])] = $delegatesData[$i]['dn']; |
| 299 |
} |
| 300 |
uksort($delegates, compareDN(...)); |
| 301 |
$return->add(new htmlSubTitle(_('Delegates'))); |
| 302 |
$delegatesContainer = new htmlTable(); |
| 303 |
if (isset($this->attributes['kolabDelegate'])) { |
| 304 |
for ($i = 0; $i < count($this->attributes['kolabDelegate']); $i++) { |
| 305 |
$delegateSelect = new htmlSelect('delegate' . $i, $delegates, [$this->attributes['kolabDelegate'][$i]]); |
| 306 |
$delegateSelect->setSortElements(false); |
| 307 |
$delegateSelect->setHasDescriptiveElements(true); |
| 308 |
$delegatesContainer->addElement($delegateSelect); |
| 309 |
$delegatesContainer->addElement(new htmlButton('delDelegate' . $i, 'del.svg', true)); |
| 310 |
if ($i === 0) { |
| 311 |
$delegatesContainer->addElement(new htmlHelpLink('delegate')); |
| 312 |
} |
| 313 |
$delegatesContainer->addNewLine(); |
| 314 |
} |
| 315 |
} |
| 316 |
// input box for new delegate |
| 317 |
$delegatesSelectNew = new htmlSelect('delegate', $delegates); |
| 318 |
$delegatesSelectNew->setHasDescriptiveElements(true); |
| 319 |
$delegatesContainer->addElement($delegatesSelectNew); |
| 320 |
$delegatesContainer->addElement(new htmlButton('addDelegate', 'add.svg', true)); |
| 321 |
if (empty($this->attributes['kolabDelegate'])) { |
| 322 |
$delegatesContainer->addElement(new htmlHelpLink('delegate')); |
| 323 |
} |
| 324 |
$return->add($delegatesContainer); |
| 325 |
$return->add(new htmlSubTitle(_('Options'))); |
| 326 |
// allowed recipients |
| 327 |
$this->addMultiValueInputTextField($return, 'kolabAllowSMTPRecipient', _('Allowed recipients')); |
| 328 |
// allowed senders |
| 329 |
$this->addMultiValueInputTextField($return, 'kolabAllowSMTPSender', _('Allowed senders')); |
| 330 |
} |
| 331 |
else { |
| 332 |
$return->add(new htmlButton('addObjectClass', _('Add Kolab extension'))); |
| 333 |
} |
| 334 |
return $return; |
| 335 |
} |
| 336 |
|
| 337 |
/** |
| 338 |
* {@inheritDoc} |
| 339 |
*/ |
| 340 |
public function process_attributes(): array { |
| 341 |
$errors = []; |
| 342 |
if (isset($_POST['addObjectClass'])) { |
| 343 |
$this->attributes['objectClass'][] = 'kolabInetOrgPerson'; |
| 344 |
$this->attributes['objectClass'][] = 'mailrecipient'; |
| 345 |
} |
| 346 |
else { |
| 347 |
if (isset($_POST['form_subpage_kolabUser_deleteUser_open'])) { |
| 348 |
return []; |
| 349 |
} |
| 350 |
$this->attributes['kolabInvitationPolicy'] = []; |
| 351 |
// check old invitation policies |
| 352 |
$policies = array_flip($this->invitationPolicies); |
| 353 |
$targets = []; |
| 354 |
$i = 0; |
| 355 |
while (isset($_POST['invPol1' . $i])) { |
| 356 |
if (isset($_POST['delInvPol' . $i])) { |
| 357 |
$i++; |
| 358 |
continue; |
| 359 |
} |
| 360 |
if (isset($_POST['invPol2' . $i]) && ($_POST['invPol1' . $i] != "") && !in_array($_POST['invPol1' . $i], $targets)) { |
| 361 |
$targets[] = $_POST['invPol1' . $i]; |
| 362 |
// check invitation policy |
| 363 |
if (!get_preg($_POST['invPol1' . $i], 'email')) { |
| 364 |
$message = $this->messages['invPol'][0]; |
| 365 |
$message[] = $_POST['invPol1' . $i]; |
| 366 |
$errors[] = $message; |
| 367 |
} |
| 368 |
else { |
| 369 |
$this->attributes['kolabInvitationPolicy'][] = $_POST['invPol1' . $i] . ':' . $policies[$_POST['invPol2' . $i]]; |
| 370 |
} |
| 371 |
} |
| 372 |
$i++; |
| 373 |
} |
| 374 |
// check new invitation policy |
| 375 |
if (isset($_POST['invPol1']) && ($_POST['invPol1'] != "") && !in_array($_POST['invPol1'], $targets)) { |
| 376 |
// check new invitation policy |
| 377 |
if (!get_preg($_POST['invPol1'], 'email')) { |
| 378 |
$message = $this->messages['invPol'][0]; |
| 379 |
$message[] = $_POST['invPol1']; |
| 380 |
$errors[] = $message; |
| 381 |
} |
| 382 |
else { |
| 383 |
$this->attributes['kolabInvitationPolicy'][] = $_POST['invPol1'] . ':' . $policies[$_POST['invPol2']]; |
| 384 |
} |
| 385 |
} |
| 386 |
// default invitation policy |
| 387 |
if (isset($_POST['defaultInvPol']) && ($_POST['defaultInvPol'] != "")) { |
| 388 |
$this->attributes['kolabInvitationPolicy'][] = $policies[$_POST['defaultInvPol']]; |
| 389 |
} |
| 390 |
// mail aliases |
| 391 |
$this->processMultiValueInputTextField('alias', $errors, 'email'); |
| 392 |
// check old delegates |
| 393 |
$this->attributes['kolabDelegate'] = []; |
| 394 |
$i = 0; |
| 395 |
while (isset($_POST['delegate' . $i])) { |
| 396 |
if (isset($_POST['delDelegate' . $i])) { |
| 397 |
$i++; |
| 398 |
continue; |
| 399 |
} |
| 400 |
$this->attributes['kolabDelegate'][] = $_POST['delegate' . $i]; |
| 401 |
$i++; |
| 402 |
} |
| 403 |
// check new delegate |
| 404 |
if (isset($_POST['addDelegate']) && ($_POST['delegate'] != "")) { |
| 405 |
$this->attributes['kolabDelegate'][] = $_POST['delegate']; |
| 406 |
} |
| 407 |
$this->attributes['kolabDelegate'] = array_unique($this->attributes['kolabDelegate']); |
| 408 |
// allowed recipients |
| 409 |
$this->processMultiValueInputTextField('kolabAllowSMTPRecipient', $errors, 'kolabEmailPrefix'); |
| 410 |
// allowed senders |
| 411 |
$this->processMultiValueInputTextField('kolabAllowSMTPSender', $errors, 'kolabEmailPrefix'); |
| 412 |
// mailbox quota |
| 413 |
if (!empty($_POST['mailQuota']) && !get_preg($_POST['mailQuota'], 'digit')) { |
| 414 |
$errors[] = $this->messages['mailQuota'][0]; |
| 415 |
} |
| 416 |
else { |
| 417 |
$mailQuota = []; |
| 418 |
if (!empty($_POST['mailQuota'])) { |
| 419 |
$mailQuota = [$_POST['mailQuota'] * 1024]; |
| 420 |
} |
| 421 |
$this->attributes['mailQuota'] = $mailQuota; |
| 422 |
} |
| 423 |
} |
| 424 |
return $errors; |
| 425 |
} |
| 426 |
|
| 427 |
/** |
| 428 |
* {@inheritDoc} |
| 429 |
*/ |
| 430 |
public function module_complete(): bool { |
| 431 |
if (isset($this->attributes['objectClass']) && in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) { |
| 432 |
$attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); |
| 433 |
if (!$attrsI['mail'][0]) { |
| 434 |
return false; |
| 435 |
} |
| 436 |
if ($this->getAccountContainer()->isNewAccount) { |
| 437 |
if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { |
| 438 |
$attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); |
| 439 |
if (!$attrsP['userpassword'][0]) { |
| 440 |
return false; |
| 441 |
} |
| 442 |
} |
| 443 |
elseif (!$attrsI['userpassword'][0]) { |
| 444 |
return false; |
| 445 |
} |
| 446 |
} |
| 447 |
} |
| 448 |
return true; |
| 449 |
} |
| 450 |
|
| 451 |
/** |
| 452 |
* {@inheritDoc} |
| 453 |
*/ |
| 454 |
public function save_attributes(): array { |
| 455 |
if (!in_array('kolabInetOrgPerson', $this->attributes['objectClass']) && !in_array('kolabInetOrgPerson', $this->orig['objectClass'])) { |
| 456 |
// skip saving if the extension was not added/modified |
| 457 |
return []; |
| 458 |
} |
| 459 |
return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); |
| 460 |
} |
| 461 |
|
| 462 |
/** |
| 463 |
* {@inheritDoc} |
| 464 |
*/ |
| 465 |
public function load_profile(array $profile): void { |
| 466 |
// profile mappings in meta data |
| 467 |
parent::load_profile($profile); |
| 468 |
// mailbox quota |
| 469 |
if (!empty($profile['kolab_mailQuota'][0])) { |
| 470 |
$this->attributes['mailQuota'][0] = intval($profile['kolab_mailQuota'][0]) * 1024; |
| 471 |
} |
| 472 |
} |
| 473 |
|
| 474 |
/** |
| 475 |
* {@inheritDoc} |
| 476 |
*/ |
| 477 |
public function build_uploadAccounts(array $rawAccounts, array $ids, array &$partialAccounts, array $selectedModules, ConfiguredType &$type): array { |
| 478 |
$messages = []; |
| 479 |
$delegates = searchLDAPByAttribute(null, null, 'inetOrgPerson', ['mail'], ['user']); |
| 480 |
for ($d = 0; $d < count($delegates); $d++) { |
| 481 |
if (isset($delegates[$d]['dn'])) { |
| 482 |
$delegates[$d] = $delegates[$d]['dn']; |
| 483 |
} |
| 484 |
} |
| 485 |
for ($i = 0; $i < count($rawAccounts); $i++) { |
| 486 |
// add object class |
| 487 |
if (!in_array("kolabInetOrgPerson", $partialAccounts[$i]['objectClass'])) { |
| 488 |
$partialAccounts[$i]['objectClass'][] = "kolabInetOrgPerson"; |
| 489 |
} |
| 490 |
if (!in_array("mailrecipient", $partialAccounts[$i]['objectClass'])) { |
| 491 |
$partialAccounts[$i]['objectClass'][] = "mailrecipient"; |
| 492 |
} |
| 493 |
// mailbox quota |
| 494 |
if (!empty($rawAccounts[$i][$ids['kolabUser_mailQuota']])) { |
| 495 |
if (get_preg($rawAccounts[$i][$ids['kolabUser_mailQuota']], 'digit')) { |
| 496 |
$partialAccounts[$i]['mailQuota'] = intval($rawAccounts[$i][$ids['kolabUser_mailQuota']]) * 1024; |
| 497 |
} |
| 498 |
else { |
| 499 |
$errMsg = $this->messages['mailQuota'][1]; |
| 500 |
$errMsg[] = [$i]; |
| 501 |
$messages[] = $errMsg; |
| 502 |
} |
| 503 |
} |
| 504 |
// add invitation policies |
| 505 |
if ($rawAccounts[$i][$ids['kolabUser_invPol']] != "") { |
| 506 |
$pols = explode(',', $rawAccounts[$i][$ids['kolabUser_invPol']]); |
| 507 |
// check format |
| 508 |
$policies = array_keys($this->invitationPolicies); |
| 509 |
$defaultFound = false; |
| 510 |
for ($p = 0; $p < count($pols); $p++) { |
| 511 |
$parts = explode(":", $pols[$p]); |
| 512 |
// default policy |
| 513 |
if (count($parts) === 1) { |
| 514 |
if (!$defaultFound && get_preg($parts[0], 'email')) { |
| 515 |
$partialAccounts[$i]['kolabInvitationPolicy'][] = $parts[0]; |
| 516 |
} |
| 517 |
else { |
| 518 |
$errMsg = $this->messages['invPol'][1]; |
| 519 |
$errMsg[] = [$i]; |
| 520 |
$messages[] = $errMsg; |
| 521 |
} |
| 522 |
$defaultFound = true; |
| 523 |
} |
| 524 |
// additional policies |
| 525 |
elseif (count($parts) === 2) { |
| 526 |
if (get_preg($parts[0], 'email') && in_array($parts[1], $policies)) { |
| 527 |
$partialAccounts[$i]['kolabInvitationPolicy'][] = $pols[$p]; |
| 528 |
} |
| 529 |
else { |
| 530 |
$errMsg = $this->messages['invPol'][1]; |
| 531 |
$errMsg[] = [$i]; |
| 532 |
$messages[] = $errMsg; |
| 533 |
} |
| 534 |
} |
| 535 |
// invalid format |
| 536 |
else { |
| 537 |
$errMsg = $this->messages['invPol'][1]; |
| 538 |
$errMsg[] = [$i]; |
| 539 |
$messages[] = $errMsg; |
| 540 |
} |
| 541 |
} |
| 542 |
} |
| 543 |
// add mail aliases |
| 544 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_aliases', 'alias', 'email', $this->messages['alias'][1], $messages, '/,[ ]*/'); |
| 545 |
// add delegates |
| 546 |
if ($rawAccounts[$i][$ids['kolabUser_delegates']] != "") { |
| 547 |
$newDelegates = explode(';', $rawAccounts[$i][$ids['kolabUser_delegates']]); |
| 548 |
// check format |
| 549 |
for ($d = 0; $d < count($newDelegates); $d++) { |
| 550 |
if (in_array($newDelegates[$d], $delegates)) { |
| 551 |
$partialAccounts[$i]['kolabDelegate'][] = $newDelegates[$d]; |
| 552 |
} |
| 553 |
// invalid format |
| 554 |
else { |
| 555 |
$errMsg = $this->messages['delegate'][0]; |
| 556 |
$errMsg[] = [$i, $newDelegates[$d]]; |
| 557 |
$messages[] = $errMsg; |
| 558 |
} |
| 559 |
} |
| 560 |
} |
| 561 |
// allowed recipients |
| 562 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_kolabAllowSMTPRecipient', 'kolabAllowSMTPRecipient', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPRecipient'][1], $messages, '/;[ ]*/'); |
| 563 |
// allowed senders |
| 564 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_kolabAllowSMTPSender', 'kolabAllowSMTPSender', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPSender'][1], $messages, '/;[ ]*/'); |
| 565 |
} |
| 566 |
return $messages; |
| 567 |
} |
| 568 |
|
| 569 |
/** |
| 570 |
* {@inheritDoc} |
| 571 |
*/ |
| 572 |
public function get_pdfEntries(array $pdfKeys, string $typeId): array { |
| 573 |
$return = []; |
| 574 |
// invitation policies |
| 575 |
if (isset($this->attributes['kolabInvitationPolicy'][0])) { |
| 576 |
// find default policy |
| 577 |
$default = ""; |
| 578 |
for ($i = 0; $i < count($this->attributes['kolabInvitationPolicy']); $i++) { |
| 579 |
if (!strpos($this->attributes['kolabInvitationPolicy'][$i], ":")) { |
| 580 |
$default = $this->attributes['kolabInvitationPolicy'][$i]; |
| 581 |
break; |
| 582 |
} |
| 583 |
} |
| 584 |
$pdfTable = new PDFTable(_('Invitation policy')); |
| 585 |
$pdfRow = new PDFTableRow(); |
| 586 |
$pdfRow->cells[] = new PDFTableCell(_('Anyone') . ": " . $this->invitationPolicies[$default]); |
| 587 |
$pdfTable->rows[] = $pdfRow; |
| 588 |
for ($i = 0; $i < count($this->attributes['kolabInvitationPolicy']); $i++) { |
| 589 |
$parts = explode(':', $this->attributes['kolabInvitationPolicy'][$i]); |
| 590 |
if (count($parts) === 2) { |
| 591 |
$pdfRow = new PDFTableRow(); |
| 592 |
$pdfRow->cells[] = new PDFTableCell($parts[0] . ": " . $this->invitationPolicies[$parts[1]]); |
| 593 |
$pdfTable->rows[] = $pdfRow; |
| 594 |
} |
| 595 |
} |
| 596 |
$this->addPDFTable($return, 'invPol', $pdfTable); |
| 597 |
} |
| 598 |
$this->addSimplePDFField($return, 'aliases', _('Email aliases'), 'alias'); |
| 599 |
$this->addSimplePDFField($return, 'delegate', _('Delegates'), 'kolabDelegate', '; '); |
| 600 |
$this->addSimplePDFField($return, 'kolabAllowSMTPRecipient', _('Allowed recipients')); |
| 601 |
$this->addSimplePDFField($return, 'kolabAllowSMTPSender', _('Allowed senders')); |
| 602 |
$mailQuota = ''; |
| 603 |
if (!empty($this->attributes['mailQuota'][0])) { |
| 604 |
$mailQuota = (((int) $this->attributes['mailQuota'][0]) / 1024) . 'MB'; |
| 605 |
} |
| 606 |
$this->addPDFKeyValue($return, 'mailQuota', _('Mailbox quota'), $mailQuota); |
| 607 |
return $return; |
| 608 |
} |
| 609 |
|
| 610 |
/** |
| 611 |
* {@inheritDoc} |
| 612 |
*/ |
| 613 |
public function getSelfServiceOptions(array $fields, array $attributes, bool $passwordChangeOnly, array $readOnlyFields): array { |
| 614 |
if ($passwordChangeOnly) { |
| 615 |
return []; // no Kolab fields as long no LDAP content can be read |
| 616 |
} |
| 617 |
if (!in_array('kolabInetOrgPerson', $attributes['objectClass'])) { |
| 618 |
return []; |
| 619 |
} |
| 620 |
$return = []; |
| 621 |
// delegates |
| 622 |
if (in_array('kolabDelegate', $fields)) { |
| 623 |
$delegates = []; |
| 624 |
$sr = @ldap_search($_SESSION['ldapHandle']->getServer(), $this->selfServiceSettings->LDAPSuffix, '(&(objectClass=inetOrgPerson)(mail=*))', ['dn'], 0, 0, 0, LDAP_DEREF_NEVER); |
| 625 |
if ($sr) { |
| 626 |
$result = ldap_get_entries($_SESSION['ldapHandle']->getServer(), $sr); |
| 627 |
cleanLDAPResult($result); |
| 628 |
for ($i = 0; $i < count($result); $i++) { |
| 629 |
$delegates[getAbstractDN($result[$i]['dn'])] = $result[$i]['dn']; |
| 630 |
} |
| 631 |
} |
| 632 |
$kolabDelegate = []; |
| 633 |
if (isset($attributes['kolabDelegate'])) { |
| 634 |
$kolabDelegate = $attributes['kolabDelegate']; |
| 635 |
// do not show existing delegation candidates in selection list |
| 636 |
for ($i = 0; $i < count($kolabDelegate); $i++) { |
| 637 |
$key = array_search($kolabDelegate[$i], $delegates); |
| 638 |
if ($key !== false) { |
| 639 |
unset($delegates[$key]); |
| 640 |
} |
| 641 |
} |
| 642 |
} |
| 643 |
uksort($delegates, compareDN(...)); |
| 644 |
$_SESSION['kolabUser_kolabDelegate'] = $kolabDelegate; |
| 645 |
$delegateContainer = new htmlTable(); |
| 646 |
for ($i = 0; $i < count($kolabDelegate); $i++) { |
| 647 |
$delegateContainer->addElement(new htmlOutputText($kolabDelegate[$i])); |
| 648 |
if (!in_array('kolabDelegate', $readOnlyFields)) { |
| 649 |
$delegateGroup = new htmlGroup(); |
| 650 |
$delCheckbox = new htmlInputCheckbox('delDelegate_' . $i, false); |
| 651 |
$delCheckbox->setAccessibilityLabel(_('Delete')); |
| 652 |
$delegateGroup->addElement($delCheckbox); |
| 653 |
$delegateGroup->addElement(new htmlOutputText(_('Delete'))); |
| 654 |
$delegateContainer->addElement(new htmlDiv(null, $delegateGroup, ['nowrap'])); |
| 655 |
} |
| 656 |
$delegateContainer->addNewLine(); |
| 657 |
} |
| 658 |
if (!in_array('kolabDelegate', $readOnlyFields)) { |
| 659 |
$delegateSelect = new htmlSelect('new_delegate_value', $delegates); |
| 660 |
$delegateSelect->setSortElements(false); |
| 661 |
$delegateSelect->setHasDescriptiveElements(true); |
| 662 |
$delegateContainer->addElement($delegateSelect); |
| 663 |
$delegateAddGroup = new htmlGroup(); |
| 664 |
$addCheckbox = new htmlInputCheckbox('new_delegate', false); |
| 665 |
$addCheckbox->setAccessibilityLabel(_("Add")); |
| 666 |
$delegateAddGroup->addElement($addCheckbox); |
| 667 |
$delegateAddGroup->addElement(new htmlOutputText(_("Add"))); |
| 668 |
$delegateContainer->addElement(new htmlDiv(null, $delegateAddGroup, ['nowrap'])); |
| 669 |
} |
| 670 |
$delegateLabel = new htmlOutputText($this->getSelfServiceLabel('kolabDelegate', _('Delegates'))); |
| 671 |
$row = new htmlResponsiveRow(); |
| 672 |
$row->addLabel($delegateLabel); |
| 673 |
$row->addField($delegateContainer); |
| 674 |
$return['kolabDelegate'] = $row; |
| 675 |
} |
| 676 |
// invitation policies |
| 677 |
if (in_array('kolabInvitationPolicy', $fields)) { |
| 678 |
$invitationContainer = new htmlTable(); |
| 679 |
// default invitation policy |
| 680 |
$defaultInvPol = $this->invitationPolicies['ACT_MANUAL']; |
| 681 |
if (!empty($attributes['kolabInvitationPolicy'])) { |
| 682 |
for ($i = 0; $i < count($attributes['kolabInvitationPolicy']); $i++) { |
| 683 |
$parts = explode(":", $attributes['kolabInvitationPolicy'][$i]); |
| 684 |
if (count($parts) === 1) { |
| 685 |
$defaultInvPol = $this->invitationPolicies[$attributes['kolabInvitationPolicy'][$i]]; |
| 686 |
unset($attributes['kolabInvitationPolicy'][$i]); |
| 687 |
$attributes['kolabInvitationPolicy'] = array_values($attributes['kolabInvitationPolicy']); |
| 688 |
break; |
| 689 |
} |
| 690 |
} |
| 691 |
} |
| 692 |
$invitationContainer->addElement(new htmlOutputText(_('Anyone'))); |
| 693 |
if (!in_array('kolabInvitationPolicy', $readOnlyFields)) { |
| 694 |
$invitationContainer->addElement(new htmlSelect('defaultInvPol', array_values($this->invitationPolicies), [$defaultInvPol]), true); |
| 695 |
} |
| 696 |
else { |
| 697 |
$invitationContainer->addElement(new htmlOutputText($defaultInvPol), true); |
| 698 |
} |
| 699 |
// other invitation policies |
| 700 |
if (!empty($attributes['kolabInvitationPolicy'])) { |
| 701 |
for ($i = 0; $i < count($attributes['kolabInvitationPolicy']); $i++) { |
| 702 |
$parts = explode(":", $attributes['kolabInvitationPolicy'][$i]); |
| 703 |
if (count($parts) === 2) { |
| 704 |
if (!in_array('kolabDelegate', $readOnlyFields)) { |
| 705 |
$newPolicyInput = new htmlInputField('invPol1' . $i, $parts[0]); |
| 706 |
$newPolicyInput->setAccessibilityLabel(_('Invitation policy')); |
| 707 |
$invitationContainer->addElement($newPolicyInput); |
| 708 |
$invitationContainer->addElement(new htmlSelect('invPol2' . $i, array_values($this->invitationPolicies), [$this->invitationPolicies[$parts[1]]])); |
| 709 |
$invPolGroup = new htmlGroup(); |
| 710 |
$delCheckbox = new htmlInputCheckbox('delInvPol' . $i, false); |
| 711 |
$delCheckbox->setAccessibilityLabel(_("Remove")); |
| 712 |
$invPolGroup->addElement($delCheckbox); |
| 713 |
$invPolGroup->addElement(new htmlOutputText(_("Remove"))); |
| 714 |
$invitationContainer->addElement(new htmlDiv(null, $invPolGroup, ['nowrap']), true); |
| 715 |
} |
| 716 |
else { |
| 717 |
$invitationContainer->addElement(new htmlOutputText($parts[0])); |
| 718 |
$invitationContainer->addElement(new htmlOutputText($this->invitationPolicies[$parts[1]]), true); |
| 719 |
} |
| 720 |
} |
| 721 |
} |
| 722 |
} |
| 723 |
// input box for new invitation policy |
| 724 |
if (!in_array('kolabDelegate', $readOnlyFields)) { |
| 725 |
$policyInput = new htmlInputField('invPol1', ''); |
| 726 |
$policyInput->setAccessibilityLabel(_('Invitation policy')); |
| 727 |
$invitationContainer->addElement($policyInput); |
| 728 |
$invitationContainer->addElement(new htmlSelect('invPol2', array_values($this->invitationPolicies))); |
| 729 |
$invPolAddGroup = new htmlGroup(); |
| 730 |
$addPolicyCheckbox = new htmlInputCheckbox('addInvPol', false); |
| 731 |
$addPolicyCheckbox->setAccessibilityLabel(_("Add")); |
| 732 |
$invPolAddGroup->addElement($addPolicyCheckbox); |
| 733 |
$invPolAddGroup->addElement(new htmlOutputText(_("Add"))); |
| 734 |
$invitationContainer->addElement(new htmlDiv(null, $invPolAddGroup, ['nowrap']), true); |
| 735 |
} |
| 736 |
$invitationLabel = new htmlOutputText($this->getSelfServiceLabel('kolabInvitationPolicy', _('Invitation policy'))); |
| 737 |
$row = new htmlResponsiveRow(); |
| 738 |
$row->addLabel($invitationLabel); |
| 739 |
$row->addField($invitationContainer); |
| 740 |
$return['kolabInvitationPolicy'] = $row; |
| 741 |
} |
| 742 |
return $return; |
| 743 |
} |
| 744 |
|
| 745 |
/** |
| 746 |
* {@inheritDoc} |
| 747 |
*/ |
| 748 |
public function checkSelfServiceOptions(array $fields, array $attributes, bool $passwordChangeOnly, array $readOnlyFields): array { |
| 749 |
$return = ['messages' => [], 'add' => [], 'del' => [], 'mod' => [], 'info' => []]; |
| 750 |
if ($passwordChangeOnly) { |
| 751 |
return $return; // skip processing if only a password change is done |
| 752 |
} |
| 753 |
if (!in_array_ignore_case('kolabInetOrgPerson', $attributes['objectClass'])) { |
| 754 |
return $return; |
| 755 |
} |
| 756 |
$attributeNames = []; // list of attributes which should be checked for modification |
| 757 |
$attributesNew = $attributes; |
| 758 |
// delegates |
| 759 |
if (in_array('kolabDelegate', $fields) && !in_array('kolabDelegate', $readOnlyFields)) { |
| 760 |
$attributeNames[] = 'kolabDelegate'; |
| 761 |
// new delegation |
| 762 |
if (isset($_POST['new_delegate']) && ($_POST['new_delegate'] == 'on')) { |
| 763 |
$attributesNew['kolabDelegate'][] = $_POST['new_delegate_value']; |
| 764 |
} |
| 765 |
// check for deleted delegations |
| 766 |
$postKeys = array_keys($_POST); |
| 767 |
for ($i = 0; $i < count($postKeys); $i++) { |
| 768 |
if (str_contains($postKeys[$i], 'delDelegate_')) { |
| 769 |
$sKey = substr($postKeys[$i], strlen('delDelegate_')); |
| 770 |
$key = array_search($_SESSION['kolabUser_kolabDelegate'][$sKey], $attributesNew['kolabDelegate']); |
| 771 |
if ($key !== false) { |
| 772 |
unset($attributesNew['kolabDelegate'][$key]); |
| 773 |
$attributesNew['kolabDelegate'] = array_values($attributesNew['kolabDelegate']); |
| 774 |
} |
| 775 |
} |
| 776 |
} |
| 777 |
} |
| 778 |
// invitation policies |
| 779 |
if (in_array('kolabInvitationPolicy', $fields) && !in_array('kolabInvitationPolicy', $readOnlyFields)) { |
| 780 |
$attributeNames[] = 'kolabInvitationPolicy'; |
| 781 |
$policies = array_flip($this->invitationPolicies); |
| 782 |
$attributesNew['kolabInvitationPolicy'] = []; |
| 783 |
// check old invitation policies |
| 784 |
$targets = []; |
| 785 |
$i = 0; |
| 786 |
while (isset($_POST['invPol1' . $i])) { |
| 787 |
if (isset($_POST['delInvPol' . $i])) { |
| 788 |
$i++; |
| 789 |
continue; |
| 790 |
} |
| 791 |
if (isset($_POST['invPol2' . $i]) && ($_POST['invPol1' . $i] != "") && !in_array($_POST['invPol1' . $i], $targets)) { |
| 792 |
$targets[] = $_POST['invPol1' . $i]; |
| 793 |
// check invitation policy |
| 794 |
if (!get_preg($_POST['invPol1' . $i], 'email')) { |
| 795 |
$message = $this->messages['invPol'][0]; |
| 796 |
$message[] = $_POST['invPol1' . $i]; |
| 797 |
$return['messages'][] = $message; |
| 798 |
} |
| 799 |
else { |
| 800 |
$attributesNew['kolabInvitationPolicy'][] = $_POST['invPol1' . $i] . ':' . $policies[$_POST['invPol2' . $i]]; |
| 801 |
} |
| 802 |
} |
| 803 |
$i++; |
| 804 |
} |
| 805 |
// check new invitation policy |
| 806 |
if (isset($_POST['invPol1']) && ($_POST['invPol1'] != "") && !in_array($_POST['invPol1'], $targets)) { |
| 807 |
// check new invitation policy |
| 808 |
if (!get_preg($_POST['invPol1'], 'email')) { |
| 809 |
$message = $this->messages['invPol'][0]; |
| 810 |
$message[] = $_POST['invPol1']; |
| 811 |
$return['messages'][] = $message; |
| 812 |
} |
| 813 |
else { |
| 814 |
$attributesNew['kolabInvitationPolicy'][] = $_POST['invPol1'] . ':' . $policies[$_POST['invPol2']]; |
| 815 |
} |
| 816 |
} |
| 817 |
// default invitation policy |
| 818 |
if (isset($_POST['defaultInvPol']) && ($_POST['defaultInvPol'] != "")) { |
| 819 |
$attributesNew['kolabInvitationPolicy'][] = $policies[$_POST['defaultInvPol']]; |
| 820 |
} |
| 821 |
} |
| 822 |
// find differences |
| 823 |
for ($i = 0; $i < count($attributeNames); $i++) { |
| 824 |
$attrName = $attributeNames[$i]; |
| 825 |
if (isset($attributes[$attrName]) && !isset($attributesNew[$attrName])) { |
| 826 |
$return['del'][$attrName] = $attributes[$attrName]; |
| 827 |
} |
| 828 |
elseif (!isset($attributes[$attrName]) && isset($attributesNew[$attrName])) { |
| 829 |
$return['add'][$attrName] = $attributesNew[$attrName]; |
| 830 |
} |
| 831 |
else { |
| 832 |
if (isset($attributes[$attrName])) { |
| 833 |
for ($a = 0; $a < count($attributes[$attrName]); $a++) { |
| 834 |
if (!in_array($attributes[$attrName][$a], $attributesNew[$attrName])) { |
| 835 |
$return['mod'][$attrName] = $attributesNew[$attrName]; |
| 836 |
break; |
| 837 |
} |
| 838 |
} |
| 839 |
} |
| 840 |
if (isset($attributesNew[$attrName])) { |
| 841 |
for ($a = 0; $a < count($attributesNew[$attrName]); $a++) { |
| 842 |
if (!in_array($attributesNew[$attrName][$a], $attributes[$attrName])) { |
| 843 |
$return['mod'][$attrName] = $attributesNew[$attrName]; |
| 844 |
break; |
| 845 |
} |
| 846 |
} |
| 847 |
} |
| 848 |
} |
| 849 |
} |
| 850 |
return $return; |
| 851 |
} |
| 852 |
|
| 853 |
} |