| 1 |
<?php |
| 2 |
/* |
| 3 |
|
| 4 |
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) |
| 5 |
Copyright (C) 2009 - 2012 Pavel Pozdnyak |
| 6 |
2009 - 2026 Roland Gruber |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with this program; if not, write to the Free Software |
| 20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 |
|
| 22 |
*/ |
| 23 |
|
| 24 |
|
| 25 |
/** |
| 26 |
* Manages the Asterisk extension of user accounts. |
| 27 |
* |
| 28 |
* @package modules |
| 29 |
* |
| 30 |
* @author Pavel Pozdnyak |
| 31 |
* @author Roland Gruber |
| 32 |
*/ |
| 33 |
|
| 34 |
use LAM\TYPES\ConfiguredType; |
| 35 |
|
| 36 |
/** |
| 37 |
* Manages the Asterisk extension of user accounts. |
| 38 |
* |
| 39 |
* @package modules |
| 40 |
*/ |
| 41 |
class asteriskAccount extends baseModule implements passwordService { |
| 42 |
|
| 43 |
private const ASTERISK_DEFAULT_REALM = "asterisk"; |
| 44 |
|
| 45 |
/** |
| 46 |
* These attributes will be ignored by default if a new account is copied from an existing one. |
| 47 |
*/ |
| 48 |
private const ATTRIBUTES_TO_IGNORE_ON_COPY = ['AstAccountCallerID', 'AstAccountRealmedPassword', |
| 49 |
'AstAccountFullContact', 'AstAccountMailbox', 'AstAccountIPAddress']; |
| 50 |
|
| 51 |
/** |
| 52 |
* Creates a new asteriskAccount object. |
| 53 |
* |
| 54 |
* @param string $scope account type (user, group, host) |
| 55 |
*/ |
| 56 |
public function __construct($scope) { |
| 57 |
// call parent constructor |
| 58 |
parent::__construct($scope); |
| 59 |
$this->autoAddObjectClasses = false; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* {@inheritDoc} |
| 64 |
*/ |
| 65 |
public function can_manage(): bool { |
| 66 |
return $this->get_scope() === 'user'; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* {@inheritDoc} |
| 71 |
*/ |
| 72 |
public function get_metaData(): array { |
| 73 |
$return = []; |
| 74 |
$return["is_base"] = false; |
| 75 |
// alias name |
| 76 |
$return["alias"] = _("Asterisk"); |
| 77 |
// module dependencies |
| 78 |
$return['dependencies'] = ['depends' => [], 'conflicts' => []]; |
| 79 |
// managed object classes |
| 80 |
$return['objectClasses'] = ['AsteriskSIPUser']; |
| 81 |
// managed attributes |
| 82 |
$return['attributes'] = ['AstAccountCallerID', 'AstAccountHost', |
| 83 |
'AstAccountRealmedPassword', 'AstAccountContext', 'AstAccountType', |
| 84 |
'AstAccountUserAgent', 'AstAccountAMAFlags', 'AstAccountCallGroup', |
| 85 |
'AstAccountDTMFMode', 'AstAccountFromUser', 'AstAccountFromDomain', |
| 86 |
'AstAccountFullContact', 'AstAccountInsecure', 'AstAccountMailbox', |
| 87 |
'AstAccountNAT', 'AstAccountDeny', 'AstAccountPermit', |
| 88 |
'AstAccountPickupGroup', 'AstAccountPort', 'AstAccountQualify', |
| 89 |
'AstAccountRestrictCID', 'AstAccountRTPTimeout', 'AstAccountRTPHoldTimeout', |
| 90 |
'AstAccountDisallowedCodec', 'AstAccountAllowedCodec', 'AstAccountMusicOnHold', |
| 91 |
'AstAccountExpirationTimestamp', 'AstAccountRegistrationContext', |
| 92 |
'AstAccountRegistrationExten', 'AstAccountCanCallForward', 'AstAccountIPAddress', |
| 93 |
'AstAccountDefaultUser', 'AstAccountRegistrationServer', 'AstAccountLastQualifyMilliseconds', |
| 94 |
]; |
| 95 |
// icon |
| 96 |
$return['icon'] = 'asterisk.png'; |
| 97 |
// self-service |
| 98 |
$return['selfServiceFieldSettings'] = [ |
| 99 |
'syncAsteriskPassword' => _('Sync Asterisk password with Unix password'), |
| 100 |
]; |
| 101 |
// self-service: fields that cannot be relabeled |
| 102 |
$return['selfServiceNoRelabelFields'] = ['syncAsteriskPassword']; |
| 103 |
// help |
| 104 |
$return['help'] = [ |
| 105 |
'AstAccountCallerID' => [ |
| 106 |
"Headline" => _("Caller ID"), 'attr' => 'AstAccountCallerID', |
| 107 |
"Text" => _("This is the ID of the user in the Asterisk database. It may contain digits and letters (e.g. user1 or 200134).") |
| 108 |
], |
| 109 |
'AstAccountHost' => [ |
| 110 |
"Headline" => _("Host"), 'attr' => 'AstAccountHost', |
| 111 |
"Text" => _("This is the machine id (e.g. IP address or host name) from which the user can call/receive calls.") |
| 112 |
], |
| 113 |
'AstAccountContext' => [ |
| 114 |
"Headline" => _("Account context"), 'attr' => 'AstAccountContext', |
| 115 |
"Text" => _("The account context stores information about the dial plan.") |
| 116 |
], |
| 117 |
'AstAccountRealmedPassword' => [ |
| 118 |
"Headline" => _("Password"), 'attr' => 'AstAccountRealmedPassword', |
| 119 |
"Text" => _("Please enter the password which you want to set for this account.") |
| 120 |
], |
| 121 |
'AstAccountType' => [ |
| 122 |
"Headline" => _("Account type"), 'attr' => 'AstAccountType', |
| 123 |
"Text" => _("Please enter the account's type (e.g. \"friend\").") |
| 124 |
], |
| 125 |
'AsteriskRealm' => [ |
| 126 |
"Headline" => _("Asterisk realm"), |
| 127 |
"Text" => _("Authentication realm for Asterisk server (default: asterisk). This value set in sip.conf (option: \"realm\").") |
| 128 |
], |
| 129 |
'AstAccountUserAgent' => [ |
| 130 |
"Headline" => _("User agent"), 'attr' => 'AstAccountUserAgent', |
| 131 |
"Text" => _("SIP user agent identification.") |
| 132 |
], |
| 133 |
'AstAccountAMAFlags' => [ |
| 134 |
"Headline" => _("AMA flags"), 'attr' => 'AstAccountAMAFlags', |
| 135 |
"Text" => _("Asterisk AMA (Automated Message Accounting) flags.") |
| 136 |
], |
| 137 |
'AstAccountCallGroup' => [ |
| 138 |
"Headline" => _("Call groups"), 'attr' => 'AstAccountCallGroup', |
| 139 |
"Text" => _("The user's call groups.") |
| 140 |
], |
| 141 |
'AstAccountDTMFMode' => [ |
| 142 |
"Headline" => _("DTMF mode"), 'attr' => 'AstAccountDTMFMode', |
| 143 |
"Text" => _("DTMF mode for SIP client configuration.") |
| 144 |
], |
| 145 |
'AstAccountFromUser' => [ |
| 146 |
"Headline" => _("From user"), 'attr' => 'AstAccountFromUser', |
| 147 |
"Text" => _("From user setting for this account.") |
| 148 |
], |
| 149 |
'AstAccountFromDomain' => [ |
| 150 |
"Headline" => _("From domain"), 'attr' => 'AstAccountFromDomain', |
| 151 |
"Text" => _("From domain setting for this account.") |
| 152 |
], |
| 153 |
'AstAccountFullContact' => [ |
| 154 |
"Headline" => _("Full contact"), 'attr' => 'AstAccountFullContact', |
| 155 |
"Text" => _("SIP URI for a realtime peer.") |
| 156 |
], |
| 157 |
'AstAccountInsecure' => [ |
| 158 |
"Headline" => _("Insecure"), 'attr' => 'AstAccountInsecure', |
| 159 |
"Text" => _("This is typically used to allow incoming calls (e.g. from FWD) while having a type=friend entry defined with username and password.") |
| 160 |
], |
| 161 |
'AstAccountMailbox' => [ |
| 162 |
"Headline" => _("Mailbox"), 'attr' => 'AstAccountMailbox', |
| 163 |
"Text" => _("Defines the mailbox to check for message waiting indication (MWI) for this peer.") |
| 164 |
], |
| 165 |
'AstAccountNAT' => [ |
| 166 |
"Headline" => _("NAT"), 'attr' => 'AstAccountNAT', |
| 167 |
"Text" => _("NAT setting for this account.") |
| 168 |
], |
| 169 |
'AstAccountDeny' => [ |
| 170 |
"Headline" => _("Deny"), 'attr' => 'AstAccountDeny', |
| 171 |
"Text" => _("Used to limit SIP traffic to and from this peer to a certain IP or network.") |
| 172 |
], |
| 173 |
'AstAccountPermit' => [ |
| 174 |
"Headline" => _("Permit"), 'attr' => 'AstAccountPermit', |
| 175 |
"Text" => _("Used to limit SIP traffic to and from this peer to a certain IP or network.") |
| 176 |
], |
| 177 |
'AstAccountPickupGroup' => [ |
| 178 |
"Headline" => _("Pickup group"), 'attr' => 'AstAccountPickupGroup', |
| 179 |
"Text" => _("Specifies the user's pickup group.") |
| 180 |
], |
| 181 |
'AstAccountPort' => [ |
| 182 |
"Headline" => _("Port"), 'attr' => 'AstAccountPort', |
| 183 |
"Text" => _("Port number.") |
| 184 |
], |
| 185 |
'AstAccountQualify' => [ |
| 186 |
"Headline" => _("Qualify"), 'attr' => 'AstAccountQualify', |
| 187 |
"Text" => _("Used to regularly check that a device is still online.") |
| 188 |
], |
| 189 |
'AstAccountRestrictCID' => [ |
| 190 |
"Headline" => _("Restrict caller ID"), 'attr' => 'AstAccountRestrictCID', |
| 191 |
"Text" => _("Use this to hide the caller ID.") |
| 192 |
], |
| 193 |
'AstAccountRTPTimeout' => [ |
| 194 |
"Headline" => _("RTP timeout"), 'attr' => 'AstAccountRTPTimeout', |
| 195 |
"Text" => _("Used to automatically hangup the call if no RTP traffic is received.") |
| 196 |
], |
| 197 |
'AstAccountRTPHoldTimeout' => [ |
| 198 |
"Headline" => _("RTP hold timeout"), 'attr' => 'AstAccountRTPHoldTimeout', |
| 199 |
"Text" => _("Maximum number of seconds of inactivity before terminating a call on hold.") |
| 200 |
], |
| 201 |
'AstAccountDisallowedCodec' => [ |
| 202 |
"Headline" => _("Disallowed codec"), 'attr' => 'AstAccountDisallowedCodec', |
| 203 |
"Text" => _("List of disallowed codecs.") |
| 204 |
], |
| 205 |
'AstAccountAllowedCodec' => [ |
| 206 |
"Headline" => _("Allowed codec"), 'attr' => 'AstAccountAllowedCodec', |
| 207 |
"Text" => _("List of allowed codecs.") |
| 208 |
], |
| 209 |
'AstAccountMusicOnHold' => [ |
| 210 |
"Headline" => _("Music on hold"), 'attr' => 'AstAccountMusicOnHold', |
| 211 |
"Text" => _("Music to play on hold.") |
| 212 |
], |
| 213 |
'AstAccountExpirationTimestamp' => [ |
| 214 |
"Headline" => _("Expiration timestamp"), 'attr' => 'AstAccountExpirationTimestamp', |
| 215 |
"Text" => _("Expiration timestamp (\"regseconds\" option).") |
| 216 |
], |
| 217 |
'AstAccountRegistrationContext' => [ |
| 218 |
"Headline" => _("Registration context"), 'attr' => 'AstAccountRegistrationContext', |
| 219 |
"Text" => _("If registration context is specified, Asterisk will dynamically create and destroy a NoOp priority 1 extension for a given peer who registers or unregisters with Asterisk.") |
| 220 |
], |
| 221 |
'AstAccountRegistrationExten' => [ |
| 222 |
"Headline" => _("Registration extension"), 'attr' => 'AstAccountRegistrationExten', |
| 223 |
"Text" => _("Used for registration context.") |
| 224 |
], |
| 225 |
'AstAccountCanCallForward' => [ |
| 226 |
"Headline" => _("Can call forward"), 'attr' => 'AstAccountCanCallForward', |
| 227 |
"Text" => _("Specifies if the user can call forward.") |
| 228 |
], |
| 229 |
'AstAccountIPAddress' => [ |
| 230 |
"Headline" => _("IP address"), 'attr' => 'AstAccountIPAddress', |
| 231 |
"Text" => _("IP address of the peer. Valid only for realtime peers.") |
| 232 |
], |
| 233 |
'AstAccountDefaultUser' => [ |
| 234 |
"Headline" => _("Default user"), 'attr' => 'AstAccountDefaultUser', |
| 235 |
"Text" => _("Authentication user for outbound proxies.") |
| 236 |
], |
| 237 |
'AstAccountRegistrationServer' => [ |
| 238 |
"Headline" => _("Registration server"), 'attr' => 'AstAccountRegistrationServer', |
| 239 |
"Text" => _("IP address or domain name of the registration server.") |
| 240 |
], |
| 241 |
'AstAccountLastQualifyMilliseconds' => [ |
| 242 |
"Headline" => _("Last qualify milliseconds"), 'attr' => 'AstAccountLastQualifyMilliseconds', |
| 243 |
"Text" => _("The number of milliseconds for the last qualify.") |
| 244 |
], |
| 245 |
'hiddenOptions' => [ |
| 246 |
"Headline" => _("Hidden options"), |
| 247 |
"Text" => _("The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields.") |
| 248 |
], |
| 249 |
]; |
| 250 |
// self-service options |
| 251 |
$selfServiceContainer = new htmlResponsiveRow(); |
| 252 |
$selfServiceContainer->add(new htmlResponsiveInputField(_('Asterisk realm'), 'asteriskAccount_AsteriskRealm', null, ['AsteriskRealm', static::class])); |
| 253 |
$return['selfServiceSettings'] = $selfServiceContainer; |
| 254 |
// profile options |
| 255 |
$profileContainer = new htmlResponsiveRow(); |
| 256 |
$profileContainer->add(new htmlResponsiveInputField(_('Host'), 'asteriskAccount_AstAccountHost', null, 'AstAccountHost')); |
| 257 |
$profileContainer->add(new htmlResponsiveInputField(_('Account context'), 'asteriskAccount_AstAccountContext', null, 'AstAccountContext')); |
| 258 |
$profileContainer->add(new htmlResponsiveInputField(_('Account type'), 'asteriskAccount_AstAccountType', null, 'AstAccountType')); |
| 259 |
$return['profile_options'] = $profileContainer; |
| 260 |
// profile mappings |
| 261 |
$return['profile_mappings'] = [ |
| 262 |
'asteriskAccount_AstAccountHost' => 'AstAccountHost', |
| 263 |
'asteriskAccount_AstAccountContext' => 'AstAccountContext', |
| 264 |
'asteriskAccount_AstAccountType' => 'AstAccountType', |
| 265 |
]; |
| 266 |
// available PDF fields |
| 267 |
$return['PDF_fields'] = [ |
| 268 |
'AstAccountCallerID' => _('Caller ID'), |
| 269 |
'AstAccountContext' => _('Account context'), |
| 270 |
'AstAccountHost' => _('Host'), |
| 271 |
'AstAccountType' => _('Account type'), |
| 272 |
'AstAccountUserAgent' => _('User agent'), |
| 273 |
'AstAccountAMAFlags' => _('AMA flags'), |
| 274 |
'AstAccountCallGroup' => _('Call groups'), |
| 275 |
'AstAccountDTMFMode' => _('DTFM flags'), |
| 276 |
'AstAccountFromUser' => _('From user'), |
| 277 |
'AstAccountFromDomain' => _('From domain'), |
| 278 |
'AstAccountFullContact' => _('Full contact'), |
| 279 |
'AstAccountInsecure' => _('Insecure'), |
| 280 |
'AstAccountMailbox' => _('Mailbox'), |
| 281 |
'AstAccountNAT' => _('NAT'), |
| 282 |
'AstAccountDeny' => _('Deny'), |
| 283 |
'AstAccountPermit' => _('Permit'), |
| 284 |
'AstAccountPickupGroup' => _('Pickup group'), |
| 285 |
'AstAccountPort' => _('Port'), |
| 286 |
'AstAccountQualify' => _('Qualify'), |
| 287 |
'AstAccountRestrictCID' => _('Restrict caller ID'), |
| 288 |
'AstAccountRTPTimeout' => _('RTP timeout'), |
| 289 |
'AstAccountRTPHoldTimeout' => _('RTP hold timeout'), |
| 290 |
'AstAccountDisallowedCodec' => _('Disallowed codec'), |
| 291 |
'AstAccountAllowedCodec' => _('Allowed codec'), |
| 292 |
'AstAccountMusicOnHold' => _('Music on hold'), |
| 293 |
'AstAccountExpirationTimestamp' => _('Expiration timestamp'), |
| 294 |
'AstAccountRegistrationContext' => _('Registration context'), |
| 295 |
'AstAccountRegistrationExten' => _('Registration extension'), |
| 296 |
'AstAccountCanCallForward' => _('Can call forward'), |
| 297 |
'AstAccountIPAddress' => _('IP address'), |
| 298 |
'AstAccountDefaultUser' => _('Default user'), |
| 299 |
'AstAccountRegistrationServer' => _('Registration server'), |
| 300 |
'AstAccountLastQualifyMilliseconds' => _('Last qualify milliseconds'), |
| 301 |
]; |
| 302 |
// upload fields |
| 303 |
$return['upload_columns'] = [ |
| 304 |
[ |
| 305 |
'name' => 'asteriskAccount_AstAccountCallerID', |
| 306 |
'description' => _('Caller ID'), |
| 307 |
'help' => 'AstAccountCallerID', |
| 308 |
'example' => '12345', |
| 309 |
'required' => true |
| 310 |
], |
| 311 |
[ |
| 312 |
'name' => 'asteriskAccount_AstAccountContext', |
| 313 |
'description' => _('Account context'), |
| 314 |
'help' => 'AstAccountContext', |
| 315 |
'example' => 'default', |
| 316 |
'required' => true |
| 317 |
], |
| 318 |
[ |
| 319 |
'name' => 'asteriskAccount_AstAccountHost', |
| 320 |
'description' => _('Host'), |
| 321 |
'help' => 'AstAccountHost', |
| 322 |
'example' => 'dynamic', |
| 323 |
'default' => 'dynamic', |
| 324 |
], |
| 325 |
[ |
| 326 |
'name' => 'asteriskAccount_AstAccountRealmedPassword', |
| 327 |
'description' => _('Password'), |
| 328 |
'help' => 'AstAccountRealmedPassword', |
| 329 |
'example' => _('secret'), |
| 330 |
], |
| 331 |
[ |
| 332 |
'name' => 'asteriskAccount_AstAccountType', |
| 333 |
'description' => _('Account type'), |
| 334 |
'help' => 'AstAccountType', |
| 335 |
'example' => 'friend', |
| 336 |
'required' => true |
| 337 |
], |
| 338 |
]; |
| 339 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountUserAgent')) { |
| 340 |
$return['upload_columns'][] = [ |
| 341 |
'name' => 'asteriskAccount_AstAccountUserAgent', |
| 342 |
'description' => _('User agent'), |
| 343 |
'help' => 'AstAccountUserAgent', |
| 344 |
]; |
| 345 |
} |
| 346 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountAMAFlags')) { |
| 347 |
$return['upload_columns'][] = [ |
| 348 |
'name' => 'asteriskAccount_AstAccountAMAFlags', |
| 349 |
'description' => _('AMA flags'), |
| 350 |
'help' => 'AstAccountAMAFlags', |
| 351 |
'example' => 'billing', |
| 352 |
]; |
| 353 |
} |
| 354 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountCallGroup')) { |
| 355 |
$return['upload_columns'][] = [ |
| 356 |
'name' => 'asteriskAccount_AstAccountCallGroup', |
| 357 |
'description' => _('Call groups'), |
| 358 |
'help' => 'AstAccountCallGroup', |
| 359 |
]; |
| 360 |
} |
| 361 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDTMFMode')) { |
| 362 |
$return['upload_columns'][] = [ |
| 363 |
'name' => 'asteriskAccount_AstAccountDTMFMode', |
| 364 |
'description' => _('DTFM flags'), |
| 365 |
'help' => 'AstAccountDTMFMode', |
| 366 |
'example' => 'auto', |
| 367 |
]; |
| 368 |
} |
| 369 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFromUser')) { |
| 370 |
$return['upload_columns'][] = [ |
| 371 |
'name' => 'asteriskAccount_AstAccountFromUser', |
| 372 |
'description' => _('From user'), |
| 373 |
'help' => 'AstAccountFromUser', |
| 374 |
]; |
| 375 |
} |
| 376 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFromDomain')) { |
| 377 |
$return['upload_columns'][] = [ |
| 378 |
'name' => 'asteriskAccount_AstAccountFromDomain', |
| 379 |
'description' => _('From domain'), |
| 380 |
'help' => 'AstAccountFromDomain', |
| 381 |
]; |
| 382 |
} |
| 383 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFullContact')) { |
| 384 |
$return['upload_columns'][] = [ |
| 385 |
'name' => 'asteriskAccount_AstAccountFullContact', |
| 386 |
'description' => _('Full contact'), |
| 387 |
'help' => 'AstAccountFullContact', |
| 388 |
]; |
| 389 |
} |
| 390 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountInsecure')) { |
| 391 |
$return['upload_columns'][] = [ |
| 392 |
'name' => 'asteriskAccount_AstAccountInsecure', |
| 393 |
'description' => _('Insecure'), |
| 394 |
'help' => 'AstAccountInsecure', |
| 395 |
'example' => 'invite', |
| 396 |
]; |
| 397 |
} |
| 398 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountMailbox')) { |
| 399 |
$return['upload_columns'][] = [ |
| 400 |
'name' => 'asteriskAccount_AstAccountMailbox', |
| 401 |
'description' => _('Mailbox'), |
| 402 |
'help' => 'AstAccountMailbox', |
| 403 |
]; |
| 404 |
} |
| 405 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountNAT')) { |
| 406 |
$return['upload_columns'][] = [ |
| 407 |
'name' => 'asteriskAccount_AstAccountNAT', |
| 408 |
'description' => _('NAT'), |
| 409 |
'help' => 'AstAccountNAT', |
| 410 |
'example' => 'never', |
| 411 |
]; |
| 412 |
} |
| 413 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDeny')) { |
| 414 |
$return['upload_columns'][] = [ |
| 415 |
'name' => 'asteriskAccount_AstAccountDeny', |
| 416 |
'description' => _('Deny'), |
| 417 |
'help' => 'AstAccountDeny', |
| 418 |
]; |
| 419 |
} |
| 420 |
|
| 421 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPermit')) { |
| 422 |
$return['upload_columns'][] = [ |
| 423 |
'name' => 'asteriskAccount_AstAccountPermit', |
| 424 |
'description' => _('Permit'), |
| 425 |
'help' => 'AstAccountPermit', |
| 426 |
]; |
| 427 |
} |
| 428 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPickupGroup')) { |
| 429 |
$return['upload_columns'][] = [ |
| 430 |
'name' => 'asteriskAccount_AstAccountPickupGroup', |
| 431 |
'description' => _('Pickup group'), |
| 432 |
'help' => 'AstAccountPickupGroup', |
| 433 |
]; |
| 434 |
} |
| 435 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPort')) { |
| 436 |
$return['upload_columns'][] = [ |
| 437 |
'name' => 'asteriskAccount_AstAccountPort', |
| 438 |
'description' => _('Port'), |
| 439 |
'help' => 'AstAccountPort', |
| 440 |
]; |
| 441 |
} |
| 442 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountQualify')) { |
| 443 |
$return['upload_columns'][] = [ |
| 444 |
'name' => 'asteriskAccount_AstAccountQualify', |
| 445 |
'description' => _('Qualify'), |
| 446 |
'help' => 'AstAccountQualify', |
| 447 |
]; |
| 448 |
} |
| 449 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRestrictCID')) { |
| 450 |
$return['upload_columns'][] = [ |
| 451 |
'name' => 'asteriskAccount_AstAccountRestrictCID', |
| 452 |
'description' => _('Restrict caller ID'), |
| 453 |
'help' => 'AstAccountRestrictCID', |
| 454 |
]; |
| 455 |
} |
| 456 |
|
| 457 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRTPTimeout')) { |
| 458 |
$return['upload_columns'][] = [ |
| 459 |
'name' => 'asteriskAccount_AstAccountRTPTimeout', |
| 460 |
'description' => _('RTP timeout'), |
| 461 |
'help' => 'AstAccountRTPTimeout', |
| 462 |
]; |
| 463 |
} |
| 464 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRTPHoldTimeout')) { |
| 465 |
$return['upload_columns'][] = [ |
| 466 |
'name' => 'asteriskAccount_AstAccountRTPHoldTimeout', |
| 467 |
'description' => _('RTP hold timeout'), |
| 468 |
'help' => 'AstAccountRTPHoldTimeout', |
| 469 |
]; |
| 470 |
} |
| 471 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDisallowedCodec')) { |
| 472 |
$return['upload_columns'][] = [ |
| 473 |
'name' => 'asteriskAccount_AstAccountDisallowedCodec', |
| 474 |
'description' => _('Disallowed codec'), |
| 475 |
'help' => 'AstAccountDisallowedCodec', |
| 476 |
]; |
| 477 |
} |
| 478 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountAllowedCodec')) { |
| 479 |
$return['upload_columns'][] = [ |
| 480 |
'name' => 'asteriskAccount_AstAccountAllowedCodec', |
| 481 |
'description' => _('Allowed codec'), |
| 482 |
'help' => 'AstAccountAllowedCodec', |
| 483 |
]; |
| 484 |
} |
| 485 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountMusicOnHold')) { |
| 486 |
$return['upload_columns'][] = [ |
| 487 |
'name' => 'asteriskAccount_AstAccountMusicOnHold', |
| 488 |
'description' => _('Music on hold'), |
| 489 |
'help' => 'AstAccountMusicOnHold', |
| 490 |
]; |
| 491 |
} |
| 492 |
|
| 493 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountExpirationTimestamp')) { |
| 494 |
$return['upload_columns'][] = [ |
| 495 |
'name' => 'asteriskAccount_AstAccountExpirationTimestamp', |
| 496 |
'description' => _('Expiration timestamp'), |
| 497 |
'help' => 'AstAccountExpirationTimestamp', |
| 498 |
]; |
| 499 |
} |
| 500 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationContext')) { |
| 501 |
$return['upload_columns'][] = [ |
| 502 |
'name' => 'asteriskAccount_AstAccountRegistrationContext', |
| 503 |
'description' => _('Registration context'), |
| 504 |
'help' => 'AstAccountRegistrationContext', |
| 505 |
]; |
| 506 |
} |
| 507 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationExten')) { |
| 508 |
$return['upload_columns'][] = [ |
| 509 |
'name' => 'asteriskAccount_AstAccountRegistrationExten', |
| 510 |
'description' => _('Registration extension'), |
| 511 |
'help' => 'AstAccountRegistrationExten', |
| 512 |
]; |
| 513 |
} |
| 514 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountCanCallForward')) { |
| 515 |
$return['upload_columns'][] = [ |
| 516 |
'name' => 'asteriskAccount_AstAccountCanCallForward', |
| 517 |
'description' => _('Can call forward'), |
| 518 |
'help' => 'AstAccountCanCallForward', |
| 519 |
]; |
| 520 |
} |
| 521 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountIPAddress')) { |
| 522 |
$return['upload_columns'][] = [ |
| 523 |
'name' => 'asteriskAccount_AstAccountIPAddress', |
| 524 |
'description' => _('IP address'), |
| 525 |
'help' => 'AstAccountIPAddress', |
| 526 |
]; |
| 527 |
} |
| 528 |
|
| 529 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDefaultUser')) { |
| 530 |
$return['upload_columns'][] = [ |
| 531 |
'name' => 'asteriskAccount_AstAccountDefaultUser', |
| 532 |
'description' => _('Default user'), |
| 533 |
'help' => 'AstAccountDefaultUser', |
| 534 |
]; |
| 535 |
} |
| 536 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationServer')) { |
| 537 |
$return['upload_columns'][] = [ |
| 538 |
'name' => 'asteriskAccount_AstAccountRegistrationServer', |
| 539 |
'description' => _('Registration server'), |
| 540 |
'help' => 'AstAccountRegistrationServer', |
| 541 |
]; |
| 542 |
} |
| 543 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountLastQualifyMilliseconds')) { |
| 544 |
$return['upload_columns'][] = [ |
| 545 |
'name' => 'asteriskAccount_AstAccountLastQualifyMilliseconds', |
| 546 |
'description' => _('Last qualify milliseconds'), |
| 547 |
'help' => 'AstAccountLastQualifyMilliseconds', |
| 548 |
]; |
| 549 |
} |
| 550 |
return $return; |
| 551 |
} |
| 552 |
|
| 553 |
/** |
| 554 |
* {@inheritDoc} |
| 555 |
*/ |
| 556 |
protected function load_Messages(): void { |
| 557 |
$this->messages['AstAccountCallerID'][0] = ['ERROR', _('Please enter a caller ID.')]; |
| 558 |
$this->messages['AstAccountCallerID'][1] = ['ERROR', _('The caller ID format is invalid.')]; |
| 559 |
$this->messages['AstAccountCallerID'][2] = ['ERROR', _('There is already another user with this caller ID.')]; |
| 560 |
$this->messages['AstAccountCallerID'][3] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountCallerID', _('The caller ID format is invalid.')]; |
| 561 |
$this->messages['AstAccountContext'][0] = ['ERROR', _('Please enter the extension context.')]; |
| 562 |
$this->messages['AstAccountContext'][1] = ['ERROR', _('The extension context is invalid.')]; |
| 563 |
$this->messages['AstAccountContext'][2] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountContext', _('The extension context is invalid.')]; |
| 564 |
$this->messages['AstAccountHost'][0] = ['ERROR', _('Please enter the host name.')]; |
| 565 |
$this->messages['AstAccountHost'][1] = ['ERROR', _('The host name is invalid.')]; |
| 566 |
$this->messages['AstAccountHost'][2] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountHost', _('The host name is invalid.')]; |
| 567 |
$this->messages['AstAccountType'][0] = ['ERROR', _('Please enter the account type.')]; |
| 568 |
$this->messages['AstAccountType'][1] = ['ERROR', _('The account type is invalid.')]; |
| 569 |
$this->messages['AstAccountType'][2] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountType', _('The account type is invalid.')]; |
| 570 |
$this->messages['AstAccountFromUser'][0] = ['ERROR', _('Please enter a valid from user.')]; |
| 571 |
$this->messages['AstAccountFromUser'][1] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountFromUser', _('Please enter a valid from user.')]; |
| 572 |
$this->messages['AstAccountFromDomain'][0] = ['ERROR', _('Please enter a valid from domain.')]; |
| 573 |
$this->messages['AstAccountFromDomain'][1] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountFromDomain', _('Please enter a valid from domain.')]; |
| 574 |
$this->messages['AstAccountPort'][0] = ['ERROR', _('Please enter a valid port number.')]; |
| 575 |
$this->messages['AstAccountPort'][1] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountPort', _('Please enter a valid port number.')]; |
| 576 |
$this->messages['AstAccountIPAddress'][0] = ['ERROR', _('The IP address is invalid.')]; |
| 577 |
$this->messages['AstAccountIPAddress'][1] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountIPAddress', _('The IP address is invalid.')]; |
| 578 |
$this->messages['AstAccountDefaultUser'][0] = ['ERROR', _('Please enter a valid default user.')]; |
| 579 |
$this->messages['AstAccountDefaultUser'][1] = ['ERROR', _('Account %s:') . ' asteriskAccount_AstAccountDefaultUser', _('Please enter a valid default user.')]; |
| 580 |
} |
| 581 |
|
| 582 |
/** |
| 583 |
* {@inheritDoc} |
| 584 |
*/ |
| 585 |
public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []): void { |
| 586 |
parent::loadAttributesFromAccountCopy($ldapAttributes, array_merge(baseModule::ATTRIBUTES_TO_IGNORE_ON_COPY_DEFAULT, self::ATTRIBUTES_TO_IGNORE_ON_COPY)); |
| 587 |
} |
| 588 |
|
| 589 |
/** |
| 590 |
* {@inheritDoc} |
| 591 |
*/ |
| 592 |
public function display_html_attributes(): htmlElement|array { |
| 593 |
$return = new htmlResponsiveRow(); |
| 594 |
if (in_array('AsteriskSIPUser', $this->attributes['objectClass'])) { |
| 595 |
// caller ID |
| 596 |
$this->addSimpleInputTextField($return, 'AstAccountCallerID', _("Caller ID"), true); |
| 597 |
// host |
| 598 |
$this->addSimpleInputTextField($return, 'AstAccountHost', _("Host"), true); |
| 599 |
// context |
| 600 |
$this->addSimpleInputTextField($return, 'AstAccountContext', _("Account context"), true); |
| 601 |
// account type |
| 602 |
$this->addSimpleInputTextField($return, 'AstAccountType', _("Account type"), true); |
| 603 |
// user agent |
| 604 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountUserAgent')) { |
| 605 |
$this->addSimpleInputTextField($return, 'AstAccountUserAgent', _("User agent")); |
| 606 |
} |
| 607 |
// AMA flags |
| 608 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountAMAFlags')) { |
| 609 |
$AstAccountAMAFlagsOptions = ['-', 'default', 'omit', 'billing', 'documentation']; |
| 610 |
$AstAccountAMAFlags = []; |
| 611 |
if (isset($this->attributes['AstAccountAMAFlags'][0])) { |
| 612 |
$AstAccountAMAFlags[] = $this->attributes['AstAccountAMAFlags'][0]; |
| 613 |
if (($this->attributes['AstAccountAMAFlags'][0] != '') && !in_array($this->attributes['AstAccountAMAFlags'][0], $AstAccountAMAFlagsOptions)) { |
| 614 |
$AstAccountAMAFlagsOptions[] = $this->attributes['AstAccountAMAFlags'][0]; |
| 615 |
} |
| 616 |
} |
| 617 |
$AstAccountAMAFlagsInput = new htmlResponsiveSelect('AstAccountAMAFlags', $AstAccountAMAFlagsOptions, $AstAccountAMAFlags, _("AMA flags"), 'AstAccountAMAFlags'); |
| 618 |
$return->add($AstAccountAMAFlagsInput); |
| 619 |
} |
| 620 |
// call groups |
| 621 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountCallGroup')) { |
| 622 |
$this->addSimpleInputTextField($return, 'AstAccountCallGroup', _("Call groups")); |
| 623 |
} |
| 624 |
// DTMF flags |
| 625 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDTMFMode')) { |
| 626 |
$AstAccountDTMFModeOptions = ['-', 'inband', 'rfc2833', 'info', 'auto']; |
| 627 |
$AstAccountDTMFMode = []; |
| 628 |
if (isset($this->attributes['AstAccountDTMFMode'][0])) { |
| 629 |
$AstAccountDTMFMode[] = $this->attributes['AstAccountDTMFMode'][0]; |
| 630 |
if (($this->attributes['AstAccountDTMFMode'][0] != '') && !in_array($this->attributes['AstAccountDTMFMode'][0], $AstAccountDTMFModeOptions)) { |
| 631 |
$AstAccountDTMFModeOptions[] = $this->attributes['AstAccountDTMFMode'][0]; |
| 632 |
} |
| 633 |
} |
| 634 |
$AstAccountDTMFModeInput = new htmlResponsiveSelect('AstAccountDTMFMode', $AstAccountDTMFModeOptions, $AstAccountDTMFMode, _("DTFM flags"), 'AstAccountDTMFMode'); |
| 635 |
$return->add($AstAccountDTMFModeInput); |
| 636 |
} |
| 637 |
// from user |
| 638 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFromUser')) { |
| 639 |
$this->addSimpleInputTextField($return, 'AstAccountFromUser', _("From user")); |
| 640 |
} |
| 641 |
// from domain |
| 642 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFromDomain')) { |
| 643 |
$this->addSimpleInputTextField($return, 'AstAccountFromDomain', _("From domain")); |
| 644 |
} |
| 645 |
// full contact |
| 646 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFullContact')) { |
| 647 |
$this->addSimpleInputTextField($return, 'AstAccountFullContact', _("Full contact")); |
| 648 |
} |
| 649 |
// insecure |
| 650 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountInsecure')) { |
| 651 |
$AstAccountInsecureOptions = ['-', 'port', 'invite', 'port,invite']; |
| 652 |
$AstAccountInsecure = []; |
| 653 |
if (isset($this->attributes['AstAccountInsecure'][0])) { |
| 654 |
$AstAccountInsecure[] = $this->attributes['AstAccountInsecure'][0]; |
| 655 |
if (($this->attributes['AstAccountInsecure'][0] != '') && !in_array($this->attributes['AstAccountInsecure'][0], $AstAccountInsecureOptions)) { |
| 656 |
$AstAccountInsecureOptions[] = $this->attributes['AstAccountInsecure'][0]; |
| 657 |
} |
| 658 |
} |
| 659 |
$AstAccountInsecureInput = new htmlResponsiveSelect('AstAccountInsecure', $AstAccountInsecureOptions, $AstAccountInsecure, _("Insecure"), 'AstAccountInsecure'); |
| 660 |
$return->add($AstAccountInsecureInput); |
| 661 |
} |
| 662 |
// mailbox |
| 663 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountMailbox')) { |
| 664 |
$this->addSimpleInputTextField($return, 'AstAccountMailbox', _("Mailbox")); |
| 665 |
} |
| 666 |
// NAT |
| 667 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountNAT')) { |
| 668 |
$AstAccountNATOptions = ['-', 'yes', 'no', 'never', 'route']; |
| 669 |
$AstAccountNAT = []; |
| 670 |
if (isset($this->attributes['AstAccountNAT'][0])) { |
| 671 |
$AstAccountNAT[] = $this->attributes['AstAccountNAT'][0]; |
| 672 |
if (($this->attributes['AstAccountNAT'][0] != '') && !in_array($this->attributes['AstAccountNAT'][0], $AstAccountNATOptions)) { |
| 673 |
$AstAccountNATOptions[] = $this->attributes['AstAccountNAT'][0]; |
| 674 |
} |
| 675 |
} |
| 676 |
$AstAccountNATInput = new htmlResponsiveSelect('AstAccountNAT', $AstAccountNATOptions, $AstAccountNAT, _("NAT"), 'AstAccountNAT'); |
| 677 |
$return->add($AstAccountNATInput); |
| 678 |
} |
| 679 |
// deny |
| 680 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDeny')) { |
| 681 |
$this->addSimpleInputTextField($return, 'AstAccountDeny', _("Deny")); |
| 682 |
} |
| 683 |
// permit |
| 684 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPermit')) { |
| 685 |
$this->addSimpleInputTextField($return, 'AstAccountPermit', _("Permit")); |
| 686 |
} |
| 687 |
// pickup group |
| 688 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPickupGroup')) { |
| 689 |
$this->addSimpleInputTextField($return, 'AstAccountPickupGroup', _("Pickup group")); |
| 690 |
} |
| 691 |
// port |
| 692 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPort')) { |
| 693 |
$AstAccountPort = $this->addSimpleInputTextField($return, 'AstAccountPort', _("Port")); |
| 694 |
$AstAccountPort->setMinimumAndMaximumNumber(1); |
| 695 |
} |
| 696 |
// qualify |
| 697 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountQualify')) { |
| 698 |
$this->addSimpleInputTextField($return, 'AstAccountQualify', _("Qualify")); |
| 699 |
} |
| 700 |
// restrict caller ID |
| 701 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRestrictCID')) { |
| 702 |
$this->addSimpleInputTextField($return, 'AstAccountRestrictCID', _("Restrict caller ID")); |
| 703 |
} |
| 704 |
// RTP timeout |
| 705 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRTPTimeout')) { |
| 706 |
$AstAccountRTPTimeout = $this->addSimpleInputTextField($return, 'AstAccountRTPTimeout', _("RTP timeout")); |
| 707 |
$AstAccountRTPTimeout->setMinimumAndMaximumNumber(-1); |
| 708 |
} |
| 709 |
// RTP hold timeout |
| 710 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRTPHoldTimeout')) { |
| 711 |
$AstAccountRTPHoldTimeoutInput = $this->addSimpleInputTextField($return, 'AstAccountRTPHoldTimeout', _("RTP hold timeout")); |
| 712 |
$AstAccountRTPHoldTimeoutInput->setMinimumAndMaximumNumber(-1); |
| 713 |
} |
| 714 |
// disallowed codec |
| 715 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDisallowedCodec')) { |
| 716 |
$this->addSimpleInputTextField($return, 'AstAccountDisallowedCodec', _("Disallowed codec")); |
| 717 |
} |
| 718 |
// allowed codec |
| 719 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountAllowedCodec')) { |
| 720 |
$this->addSimpleInputTextField($return, 'AstAccountAllowedCodec', _("Allowed codec")); |
| 721 |
} |
| 722 |
// music on hold |
| 723 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountMusicOnHold')) { |
| 724 |
$this->addSimpleInputTextField($return, 'AstAccountMusicOnHold', _("Music on hold")); |
| 725 |
} |
| 726 |
// expiration timestamp |
| 727 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountExpirationTimestamp')) { |
| 728 |
$this->addSimpleInputTextField($return, 'AstAccountExpirationTimestamp', _("Expiration timestamp")); |
| 729 |
} |
| 730 |
// registration context |
| 731 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationContext')) { |
| 732 |
$this->addSimpleInputTextField($return, 'AstAccountRegistrationContext', _("Registration context")); |
| 733 |
} |
| 734 |
// registration extension |
| 735 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationExten')) { |
| 736 |
$this->addSimpleInputTextField($return, 'AstAccountRegistrationExten', _("Registration extension")); |
| 737 |
} |
| 738 |
// can call forward |
| 739 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountCanCallForward')) { |
| 740 |
$AstAccountCanCallForwardOptions = ['-', 'yes', 'no']; |
| 741 |
$AstAccountCanCallForward = []; |
| 742 |
if (isset($this->attributes['AstAccountCanCallForward'][0])) { |
| 743 |
$AstAccountCanCallForward[] = $this->attributes['AstAccountCanCallForward'][0]; |
| 744 |
if (($this->attributes['AstAccountCanCallForward'][0] != '') && !in_array($this->attributes['AstAccountCanCallForward'][0], $AstAccountCanCallForwardOptions)) { |
| 745 |
$AstAccountCanCallForwardOptions[] = $this->attributes['AstAccountCanCallForward'][0]; |
| 746 |
} |
| 747 |
} |
| 748 |
$AstAccountCanCallForwardInput = new htmlResponsiveSelect('AstAccountCanCallForward', $AstAccountCanCallForwardOptions, $AstAccountCanCallForward, _("Can call forward"), 'AstAccountCanCallForward'); |
| 749 |
$return->add($AstAccountCanCallForwardInput); |
| 750 |
} |
| 751 |
// IP address |
| 752 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountIPAddress')) { |
| 753 |
$this->addSimpleInputTextField($return, 'AstAccountIPAddress', _("IP address")); |
| 754 |
} |
| 755 |
// default user |
| 756 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDefaultUser')) { |
| 757 |
$this->addSimpleInputTextField($return, 'AstAccountDefaultUser', _("Default user")); |
| 758 |
} |
| 759 |
// registration server |
| 760 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationServer')) { |
| 761 |
$this->addSimpleInputTextField($return, 'AstAccountRegistrationServer', _("Registration server")); |
| 762 |
} |
| 763 |
// last qualify milliseconds |
| 764 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountLastQualifyMilliseconds')) { |
| 765 |
$this->addSimpleInputTextField($return, 'AstAccountLastQualifyMilliseconds', _("Last qualify milliseconds")); |
| 766 |
} |
| 767 |
} |
| 768 |
else { |
| 769 |
$return->add(new htmlButton('addObjectClass', _('Add Asterisk account'))); |
| 770 |
} |
| 771 |
return $return; |
| 772 |
} |
| 773 |
|
| 774 |
/** |
| 775 |
* {@inheritDoc} |
| 776 |
*/ |
| 777 |
public function process_attributes(): array { |
| 778 |
if (isset($_POST['addObjectClass'])) { |
| 779 |
$this->attributes['objectClass'][] = 'AsteriskSIPUser'; |
| 780 |
return []; |
| 781 |
} |
| 782 |
if (!in_array('AsteriskSIPUser', $this->attributes['objectClass'])) { |
| 783 |
return []; |
| 784 |
} |
| 785 |
$errors = []; |
| 786 |
$this->attributes['AstAccountCallerID'] = []; |
| 787 |
$this->attributes['AstAccountHost'] = []; |
| 788 |
$this->attributes['AstAccountContext'] = []; |
| 789 |
$this->attributes['AstAccountType'] = []; |
| 790 |
if (isset($_POST['AstAccountCallerID'])) { |
| 791 |
$this->attributes['AstAccountCallerID'][0] = $_POST['AstAccountCallerID']; |
| 792 |
// check if caller ID is empty |
| 793 |
if ($this->attributes['AstAccountCallerID'][0] == '') { |
| 794 |
$errors[] = $this->messages['AstAccountCallerID'][0]; |
| 795 |
} |
| 796 |
// check format |
| 797 |
elseif (!get_preg($this->attributes['AstAccountCallerID'][0], 'username')) { |
| 798 |
$errors[] = $this->messages['AstAccountCallerID'][1]; |
| 799 |
} |
| 800 |
// check for duplicate caller ID |
| 801 |
elseif (!isset($this->orig['AstAccountCallerID'][0]) |
| 802 |
|| ($this->orig['AstAccountCallerID'][0] != $this->attributes['AstAccountCallerID'][0])) { |
| 803 |
$entries = searchLDAPByAttribute('AstAccountCallerID', $this->attributes['AstAccountCallerID'][0], 'AsteriskSIPUser', ['dn'], ['user']); |
| 804 |
if (count($entries) > 0) { |
| 805 |
$errors[] = $this->messages['AstAccountCallerID'][2]; |
| 806 |
} |
| 807 |
} |
| 808 |
} |
| 809 |
if (isset($_POST['AstAccountHost'])) { |
| 810 |
$this->attributes['AstAccountHost'][0] = $_POST['AstAccountHost']; |
| 811 |
if ($this->attributes['AstAccountHost'][0] == '') { |
| 812 |
$errors[] = $this->messages['AstAccountHost'][0]; |
| 813 |
} |
| 814 |
elseif (!get_preg($this->attributes['AstAccountHost'][0], 'hostname')) { |
| 815 |
$errors[] = $this->messages['AstAccountHost'][1]; |
| 816 |
} |
| 817 |
} |
| 818 |
if (isset($_POST['AstAccountContext'])) { |
| 819 |
$this->attributes['AstAccountContext'][0] = $_POST['AstAccountContext']; |
| 820 |
if ($this->attributes['AstAccountContext'][0] == '') { |
| 821 |
$errors[] = $this->messages['AstAccountContext'][0]; |
| 822 |
} |
| 823 |
elseif (!get_preg($this->attributes['AstAccountContext'][0], 'username')) { |
| 824 |
$errors[] = $this->messages['AstAccountContext'][1]; |
| 825 |
} |
| 826 |
} |
| 827 |
if (isset($_POST['AstAccountType'])) { |
| 828 |
$this->attributes['AstAccountType'][0] = $_POST['AstAccountType']; |
| 829 |
if ($this->attributes['AstAccountType'][0] == '') { |
| 830 |
$errors[] = $this->messages['AstAccountType'][0]; |
| 831 |
} |
| 832 |
elseif (!get_preg($this->attributes['AstAccountType'][0], 'username')) { |
| 833 |
$errors[] = $this->messages['AstAccountType'][1]; |
| 834 |
} |
| 835 |
} |
| 836 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountUserAgent')) { |
| 837 |
$this->attributes['AstAccountUserAgent'][0] = $_POST['AstAccountUserAgent']; |
| 838 |
} |
| 839 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountAMAFlags')) { |
| 840 |
if (($_POST['AstAccountAMAFlags'] == '-') && isset($this->attributes['AstAccountAMAFlags'][0])) { |
| 841 |
unset($this->attributes['AstAccountAMAFlags'][0]); |
| 842 |
} |
| 843 |
else { |
| 844 |
$this->attributes['AstAccountAMAFlags'][0] = $_POST['AstAccountAMAFlags']; |
| 845 |
} |
| 846 |
} |
| 847 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountCallGroup')) { |
| 848 |
$this->attributes['AstAccountCallGroup'][0] = $_POST['AstAccountCallGroup']; |
| 849 |
} |
| 850 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDTMFMode')) { |
| 851 |
if (($_POST['AstAccountDTMFMode'] == '-') && isset($this->attributes['AstAccountDTMFMode'][0])) { |
| 852 |
unset($this->attributes['AstAccountDTMFMode'][0]); |
| 853 |
} |
| 854 |
else { |
| 855 |
$this->attributes['AstAccountDTMFMode'][0] = $_POST['AstAccountDTMFMode']; |
| 856 |
} |
| 857 |
} |
| 858 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFromUser')) { |
| 859 |
$this->attributes['AstAccountFromUser'][0] = $_POST['AstAccountFromUser']; |
| 860 |
if (($_POST['AstAccountFromUser'] != '') && !get_preg($_POST['AstAccountFromUser'], 'username')) { |
| 861 |
$errors[] = $this->messages['AstAccountFromUser'][0]; |
| 862 |
} |
| 863 |
} |
| 864 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFromDomain')) { |
| 865 |
$this->attributes['AstAccountFromDomain'][0] = $_POST['AstAccountFromDomain']; |
| 866 |
if (($_POST['AstAccountFromDomain'] != '') && !get_preg($_POST['AstAccountFromDomain'], 'domainname')) { |
| 867 |
$errors[] = $this->messages['AstAccountFromDomain'][0]; |
| 868 |
} |
| 869 |
} |
| 870 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountFullContact')) { |
| 871 |
$this->attributes['AstAccountFullContact'][0] = $_POST['AstAccountFullContact']; |
| 872 |
} |
| 873 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountInsecure')) { |
| 874 |
if (($_POST['AstAccountInsecure'] == '-') && isset($this->attributes['AstAccountInsecure'][0])) { |
| 875 |
unset($this->attributes['AstAccountInsecure'][0]); |
| 876 |
} |
| 877 |
else { |
| 878 |
$this->attributes['AstAccountInsecure'][0] = $_POST['AstAccountInsecure']; |
| 879 |
} |
| 880 |
} |
| 881 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountMailbox')) { |
| 882 |
$this->attributes['AstAccountMailbox'][0] = $_POST['AstAccountMailbox']; |
| 883 |
} |
| 884 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountNAT')) { |
| 885 |
if (($_POST['AstAccountNAT'] == '-') && isset($this->attributes['AstAccountNAT'][0])) { |
| 886 |
unset($this->attributes['AstAccountNAT'][0]); |
| 887 |
} |
| 888 |
else { |
| 889 |
$this->attributes['AstAccountNAT'][0] = $_POST['AstAccountNAT']; |
| 890 |
} |
| 891 |
} |
| 892 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDeny')) { |
| 893 |
$this->attributes['AstAccountDeny'][0] = $_POST['AstAccountDeny']; |
| 894 |
} |
| 895 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPermit')) { |
| 896 |
$this->attributes['AstAccountPermit'][0] = $_POST['AstAccountPermit']; |
| 897 |
} |
| 898 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPickupGroup')) { |
| 899 |
$this->attributes['AstAccountPickupGroup'][0] = $_POST['AstAccountPickupGroup']; |
| 900 |
} |
| 901 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountPort')) { |
| 902 |
$this->attributes['AstAccountPort'][0] = $_POST['AstAccountPort']; |
| 903 |
if (($_POST['AstAccountPort'] != '') && !get_preg($_POST['AstAccountPort'], 'digit')) { |
| 904 |
$errors[] = $this->messages['AstAccountPort'][0]; |
| 905 |
} |
| 906 |
} |
| 907 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountQualify')) { |
| 908 |
$this->attributes['AstAccountQualify'][0] = $_POST['AstAccountQualify']; |
| 909 |
} |
| 910 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRestrictCID')) { |
| 911 |
$this->attributes['AstAccountRestrictCID'][0] = $_POST['AstAccountRestrictCID']; |
| 912 |
} |
| 913 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRTPTimeout')) { |
| 914 |
$this->attributes['AstAccountRTPTimeout'][0] = $_POST['AstAccountRTPTimeout']; |
| 915 |
} |
| 916 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRTPHoldTimeout')) { |
| 917 |
$this->attributes['AstAccountRTPHoldTimeout'][0] = $_POST['AstAccountRTPHoldTimeout']; |
| 918 |
} |
| 919 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDisallowedCodec')) { |
| 920 |
$this->attributes['AstAccountDisallowedCodec'][0] = $_POST['AstAccountDisallowedCodec']; |
| 921 |
} |
| 922 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountAllowedCodec')) { |
| 923 |
$this->attributes['AstAccountAllowedCodec'][0] = $_POST['AstAccountAllowedCodec']; |
| 924 |
} |
| 925 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountMusicOnHold')) { |
| 926 |
$this->attributes['AstAccountMusicOnHold'][0] = $_POST['AstAccountMusicOnHold']; |
| 927 |
} |
| 928 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountExpirationTimestamp')) { |
| 929 |
$this->attributes['AstAccountExpirationTimestamp'][0] = $_POST['AstAccountExpirationTimestamp']; |
| 930 |
} |
| 931 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationContext')) { |
| 932 |
$this->attributes['AstAccountRegistrationContext'][0] = $_POST['AstAccountRegistrationContext']; |
| 933 |
} |
| 934 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationExten')) { |
| 935 |
$this->attributes['AstAccountRegistrationExten'][0] = $_POST['AstAccountRegistrationExten']; |
| 936 |
} |
| 937 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountCanCallForward')) { |
| 938 |
if (($_POST['AstAccountCanCallForward'] == '-') && isset($this->attributes['AstAccountCanCallForward'][0])) { |
| 939 |
unset($this->attributes['AstAccountCanCallForward'][0]); |
| 940 |
} |
| 941 |
else { |
| 942 |
$this->attributes['AstAccountCanCallForward'][0] = $_POST['AstAccountCanCallForward']; |
| 943 |
} |
| 944 |
} |
| 945 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountIPAddress')) { |
| 946 |
$this->attributes['AstAccountIPAddress'][0] = $_POST['AstAccountIPAddress']; |
| 947 |
if (($_POST['AstAccountIPAddress'] != '') && !get_preg($_POST['AstAccountIPAddress'], 'ip')) { |
| 948 |
$errors[] = $this->messages['AstAccountIPAddress'][0]; |
| 949 |
} |
| 950 |
} |
| 951 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountDefaultUser')) { |
| 952 |
$this->attributes['AstAccountDefaultUser'][0] = $_POST['AstAccountDefaultUser']; |
| 953 |
if (($_POST['AstAccountDefaultUser'] != '') && !get_preg($_POST['AstAccountDefaultUser'], 'username')) { |
| 954 |
$errors[] = $this->messages['AstAccountDefaultUser'][0]; |
| 955 |
} |
| 956 |
} |
| 957 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountRegistrationServer')) { |
| 958 |
$this->attributes['AstAccountRegistrationServer'][0] = $_POST['AstAccountRegistrationServer']; |
| 959 |
} |
| 960 |
if (!$this->isBooleanConfigOptionSet('asteriskAccount_hideAstAccountLastQualifyMilliseconds')) { |
| 961 |
$this->attributes['AstAccountLastQualifyMilliseconds'][0] = $_POST['AstAccountLastQualifyMilliseconds']; |
| 962 |
} |
| 963 |
return $errors; |
| 964 |
} |
| 965 |
|
| 966 |
/** |
| 967 |
* {@inheritDoc} |
| 968 |
*/ |
| 969 |
public function save_attributes(): array { |
| 970 |
if (!in_array('AsteriskSIPUser', $this->attributes['objectClass'])) { |
| 971 |
return []; |
| 972 |
} |
| 973 |
return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); |
| 974 |
} |
| 975 |
|
| 976 |
/** |
| 977 |
* {@inheritDoc} |
| 978 |
*/ |
| 979 |
public function get_pdfEntries(array $pdfKeys, string $typeId): array { |
| 980 |
$return = []; |
| 981 |
$this->addSimplePDFField($return, 'AstAccountCallerID', _('Caller ID')); |
| 982 |
$this->addSimplePDFField($return, 'AstAccountContext', _('Account context')); |
| 983 |
$this->addSimplePDFField($return, 'AstAccountHost', _('Host')); |
| 984 |
$this->addSimplePDFField($return, 'AstAccountType', _('Account type')); |
| 985 |
$this->addSimplePDFField($return, 'AstAccountUserAgent', _('User agent')); |
| 986 |
$this->addSimplePDFField($return, 'AstAccountAMAFlags', _('AMA flags')); |
| 987 |
$this->addSimplePDFField($return, 'AstAccountCallGroup', _('Call groups')); |
| 988 |
$this->addSimplePDFField($return, 'AstAccountDTMFMode', _('DTMF mode')); |
| 989 |
$this->addSimplePDFField($return, 'AstAccountFromUser', _('From user')); |
| 990 |
$this->addSimplePDFField($return, 'AstAccountFromDomain', _('From domain')); |
| 991 |
$this->addSimplePDFField($return, 'AstAccountFullContact', _('Full contact')); |
| 992 |
$this->addSimplePDFField($return, 'AstAccountInsecure', _('Insecure')); |
| 993 |
$this->addSimplePDFField($return, 'AstAccountMailbox', _('Mailbox')); |
| 994 |
$this->addSimplePDFField($return, 'AstAccountNAT', _('NAT')); |
| 995 |
$this->addSimplePDFField($return, 'AstAccountDeny', _('Deny')); |
| 996 |
$this->addSimplePDFField($return, 'AstAccountPermit', _('Permit')); |
| 997 |
$this->addSimplePDFField($return, 'AstAccountPickupGroup', _('Pickup group')); |
| 998 |
$this->addSimplePDFField($return, 'AstAccountPort', _('Port')); |
| 999 |
$this->addSimplePDFField($return, 'AstAccountQualify', _('Qualify')); |
| 1000 |
$this->addSimplePDFField($return, 'AstAccountRestrictCID', _('Restrict caller ID')); |
| 1001 |
$this->addSimplePDFField($return, 'AstAccountRTPTimeout', _('RTP timeout')); |
| 1002 |
$this->addSimplePDFField($return, 'AstAccountRTPHoldTimeout', _('RTP hold timeout')); |
| 1003 |
$this->addSimplePDFField($return, 'AstAccountDisallowedCodec', _('Disallowed codec')); |
| 1004 |
$this->addSimplePDFField($return, 'AstAccountAllowedCodec', _('Allowed codec')); |
| 1005 |
$this->addSimplePDFField($return, 'AstAccountMusicOnHold', _('Music on hold')); |
| 1006 |
$this->addSimplePDFField($return, 'AstAccountExpirationTimestamp', _('Expiration timestamp')); |
| 1007 |
$this->addSimplePDFField($return, 'AstAccountRegistrationContext', _('Registration context')); |
| 1008 |
$this->addSimplePDFField($return, 'AstAccountRegistrationExten', _('Registration extension')); |
| 1009 |
$this->addSimplePDFField($return, 'AstAccountCanCallForward', _('Can call forward')); |
| 1010 |
$this->addSimplePDFField($return, 'AstAccountIPAddress', _('IP address')); |
| 1011 |
$this->addSimplePDFField($return, 'AstAccountDefaultUser', _('Default user')); |
| 1012 |
$this->addSimplePDFField($return, 'AstAccountRegistrationServer', _('Registration server')); |
| 1013 |
$this->addSimplePDFField($return, 'AstAccountLastQualifyMilliseconds', _('Last qualify milliseconds')); |
| 1014 |
return $return; |
| 1015 |
} |
| 1016 |
|
| 1017 |
/** |
| 1018 |
* {@inheritDoc} |
| 1019 |
*/ |
| 1020 |
public function build_uploadAccounts(array $rawAccounts, array $ids, array &$partialAccounts, array $selectedModules, ConfiguredType &$type): array { |
| 1021 |
$messages = []; |
| 1022 |
for ($i = 0; $i < count($rawAccounts); $i++) { |
| 1023 |
// add object class |
| 1024 |
if (!in_array("AsteriskSIPUser", $partialAccounts[$i]['objectClass'])) { |
| 1025 |
$partialAccounts[$i]['objectClass'][] = "AsteriskSIPUser"; |
| 1026 |
} |
| 1027 |
// add account caller id |
| 1028 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountCallerID', 'AstAccountCallerID', |
| 1029 |
'username', $this->messages['AstAccountCallerID'][3], $messages); |
| 1030 |
// add host |
| 1031 |
if (empty($rawAccounts[$i][$ids['asteriskAccount_AstAccountHost']])) { |
| 1032 |
// default value |
| 1033 |
$partialAccounts[$i]['AstAccountHost'] = 'dynamic'; |
| 1034 |
} |
| 1035 |
else { |
| 1036 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountHost', 'AstAccountHost', |
| 1037 |
'realname', $this->messages['AstAccountHost'][2], $messages); |
| 1038 |
} |
| 1039 |
//add context |
| 1040 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountContext', 'AstAccountContext', |
| 1041 |
'realname', $this->messages['AstAccountContext'][2], $messages); |
| 1042 |
//add account type |
| 1043 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountType', 'AstAccountType', |
| 1044 |
'username', $this->messages['AstAccountType'][2], $messages); |
| 1045 |
//add password |
| 1046 |
if ($rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']] != "") { |
| 1047 |
$attributes = ['AstAccountCallerID' => $partialAccounts[$i]['AstAccountCallerID']]; // fake attribute list for password building |
| 1048 |
$pwdString = asteriskAccount::buildPasswordString($attributes, $this->moduleSettings, $rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']]); |
| 1049 |
$partialAccounts[$i]['AstAccountRealmedPassword'] = $pwdString; |
| 1050 |
} |
| 1051 |
|
| 1052 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountUserAgent', 'AstAccountUserAgent'); |
| 1053 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountAMAFlags', 'AstAccountAMAFlags'); |
| 1054 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountCallGroup', 'AstAccountCallGroup'); |
| 1055 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDTMFMode', 'AstAccountDTMFMode'); |
| 1056 |
|
| 1057 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountFromUser', 'AstAccountFromUser', |
| 1058 |
'username', $this->messages['AstAccountFromUser'][1], $messages); |
| 1059 |
|
| 1060 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountFromDomain', 'AstAccountFromDomain', |
| 1061 |
'domainname', $this->messages['AstAccountFromDomain'][1], $messages); |
| 1062 |
|
| 1063 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountFullContact', 'AstAccountFullContact'); |
| 1064 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountInsecure', 'AstAccountInsecure'); |
| 1065 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountMailbox', 'AstAccountMailbox'); |
| 1066 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountNAT', 'AstAccountNAT'); |
| 1067 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDeny', 'AstAccountDeny'); |
| 1068 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountPermit', 'AstAccountPermit'); |
| 1069 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountPickupGroup', 'AstAccountPickupGroup'); |
| 1070 |
|
| 1071 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountPort', 'AstAccountPort', |
| 1072 |
'digit', $this->messages['AstAccountPort'][1], $messages); |
| 1073 |
|
| 1074 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountQualify', 'AstAccountQualify'); |
| 1075 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRestrictCID', 'AstAccountRestrictCID'); |
| 1076 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRTPTimeout', 'AstAccountRTPTimeout'); |
| 1077 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRTPHoldTimeout', 'AstAccountRTPHoldTimeout'); |
| 1078 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDisallowedCodec', 'AstAccountDisallowedCodec'); |
| 1079 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountAllowedCodec', 'AstAccountAllowedCodec'); |
| 1080 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountMusicOnHold', 'AstAccountMusicOnHold'); |
| 1081 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountExpirationTimestamp', 'AstAccountExpirationTimestamp'); |
| 1082 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRegistrationContext', 'AstAccountRegistrationContext'); |
| 1083 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRegistrationExten', 'AstAccountRegistrationExten'); |
| 1084 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountCanCallForward', 'AstAccountCanCallForward'); |
| 1085 |
|
| 1086 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountIPAddress', 'AstAccountIPAddress', |
| 1087 |
'ip', $this->messages['AstAccountIPAddress'][1], $messages); |
| 1088 |
|
| 1089 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDefaultUser', 'AstAccountDefaultUser', |
| 1090 |
'username', $this->messages['AstAccountDefaultUser'][1], $messages); |
| 1091 |
|
| 1092 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRegistrationServer', 'AstAccountRegistrationServer'); |
| 1093 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountLastQualifyMilliseconds', 'AstAccountLastQualifyMilliseconds'); |
| 1094 |
} |
| 1095 |
return $messages; |
| 1096 |
} |
| 1097 |
|
| 1098 |
|
| 1099 |
/** |
| 1100 |
* {@inheritDoc} |
| 1101 |
*/ |
| 1102 |
public function managesPasswordAttributes(): bool { |
| 1103 |
return in_array('AsteriskSIPUser', $this->attributes['objectClass']); |
| 1104 |
} |
| 1105 |
|
| 1106 |
/** |
| 1107 |
* {@inheritDoc} |
| 1108 |
*/ |
| 1109 |
public function supportsForcePasswordChange(): bool { |
| 1110 |
return false; |
| 1111 |
} |
| 1112 |
|
| 1113 |
/** |
| 1114 |
* {@inheritDoc} |
| 1115 |
*/ |
| 1116 |
public function passwordChangeRequested(string $password, array $modules, bool $forcePasswordChange): array { |
| 1117 |
if (!in_array(static::class, $modules)) { |
| 1118 |
return []; |
| 1119 |
} |
| 1120 |
$this->attributes['AstAccountRealmedPassword'][0] = asteriskAccount::buildPasswordString($this->attributes, $this->moduleSettings, $password); |
| 1121 |
return []; |
| 1122 |
} |
| 1123 |
|
| 1124 |
/** |
| 1125 |
* Builds the password string for the password attribute. |
| 1126 |
* |
| 1127 |
* @param array<string, string[]|string> $attributes LDAP attributes |
| 1128 |
* @param array<string, string[]> $moduleSettings module configuration settings |
| 1129 |
* @param string $password password |
| 1130 |
* @return string value for password attribute |
| 1131 |
*/ |
| 1132 |
public static function buildPasswordString(&$attributes, &$moduleSettings, $password): string { |
| 1133 |
$astRealm = self::ASTERISK_DEFAULT_REALM; |
| 1134 |
if (!empty($moduleSettings['asteriskAccount_AsteriskRealm'][0])) { |
| 1135 |
$astRealm = $moduleSettings['asteriskAccount_AsteriskRealm'][0]; |
| 1136 |
} |
| 1137 |
return asteriskAccount::hashPassword($attributes['AstAccountCallerID'][0] . ":" . $astRealm . ":" . $password); |
| 1138 |
} |
| 1139 |
|
| 1140 |
/** |
| 1141 |
* Hashes a password value to Asterisk format. |
| 1142 |
* |
| 1143 |
* @param string $password password |
| 1144 |
* @return string hash |
| 1145 |
*/ |
| 1146 |
private static function hashPassword(string $password): string { |
| 1147 |
return "{MD5}" . md5($password); |
| 1148 |
} |
| 1149 |
|
| 1150 |
/** |
| 1151 |
* {@inheritDoc} |
| 1152 |
*/ |
| 1153 |
public function checkSelfServiceOptions(array $fields, array $attributes, bool $passwordChangeOnly, array $readOnlyFields): array { |
| 1154 |
$return = ['messages' => [], 'add' => [], 'del' => [], 'mod' => [], 'info' => []]; |
| 1155 |
if (!isset($attributes['objectClass']) || !in_array_ignore_case('AsteriskSIPUser', $attributes['objectClass'])) { |
| 1156 |
return $return; |
| 1157 |
} |
| 1158 |
if (isset($_POST['posixAccount_password']) && ($_POST['posixAccount_password'] != '')) { |
| 1159 |
if ($_POST['posixAccount_password'] != $_POST['posixAccount_password2']) { |
| 1160 |
return $return; |
| 1161 |
} |
| 1162 |
elseif (!get_preg($_POST['posixAccount_password'], 'password')) { |
| 1163 |
return $return; |
| 1164 |
} |
| 1165 |
elseif (in_array('syncAsteriskPassword', $fields)) { |
| 1166 |
// sync password |
| 1167 |
$return['mod']['AstAccountRealmedPassword'][0] = asteriskAccount::buildPasswordString($attributes, $this->selfServiceSettings->moduleSettings, $_POST['posixAccount_password']); |
| 1168 |
} |
| 1169 |
} |
| 1170 |
return $return; |
| 1171 |
} |
| 1172 |
|
| 1173 |
/** |
| 1174 |
* {@inheritDoc} |
| 1175 |
*/ |
| 1176 |
public function get_configOptions(array $scopes, array $allScopes): htmlElement|array { |
| 1177 |
$configContainer = new htmlResponsiveRow(); |
| 1178 |
$configContainer->add(new htmlResponsiveInputField(_('Asterisk realm'), 'asteriskAccount_AsteriskRealm', null, 'AsteriskRealm')); |
| 1179 |
$configContainer->addVerticalSpacer('1rem'); |
| 1180 |
$configHiddenHead = new htmlGroup(); |
| 1181 |
$configHiddenHead->addElement(new htmlOutputText(_('Hidden options'))); |
| 1182 |
$configHiddenHead->addElement(new htmlHelpLink('hiddenOptions')); |
| 1183 |
$configContainer->add($configHiddenHead); |
| 1184 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountUserAgent', false, _('User agent'), null, true), 12, 4); |
| 1185 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountAMAFlags', false, _('AMA flags'), null, true), 12, 4); |
| 1186 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountCallGroup', false, _('Call groups'), null, true), 12, 4); |
| 1187 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountDTMFMode', false, _('DTFM flags'), null, true), 12, 4); |
| 1188 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountFromUser', false, _('From user'), null, true), 12, 4); |
| 1189 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountFromDomain', false, _('From domain'), null, true), 12, 4); |
| 1190 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountFullContact', false, _('Full contact'), null, true), 12, 4); |
| 1191 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountInsecure', false, _('Insecure'), null, true), 12, 4); |
| 1192 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountMailbox', false, _('Mailbox'), null, true), 12, 4); |
| 1193 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountNAT', false, _('NAT'), null, true), 12, 4); |
| 1194 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountDeny', false, _('Deny'), null, true), 12, 4); |
| 1195 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountPermit', false, _('Permit'), null, true), 12, 4); |
| 1196 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountPickupGroup', false, _('Pickup group'), null, true), 12, 4); |
| 1197 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountPort', false, _('Port'), null, true), 12, 4); |
| 1198 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountQualify', false, _('Qualify'), null, true), 12, 4); |
| 1199 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountRestrictCID', false, _('Restrict caller ID'), null, true), 12, 4); |
| 1200 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountRTPTimeout', false, _('RTP timeout'), null, true), 12, 4); |
| 1201 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountRTPHoldTimeout', false, _('RTP hold timeout'), null, true), 12, 4); |
| 1202 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountDisallowedCodec', false, _('Disallowed codec'), null, true), 12, 4); |
| 1203 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountAllowedCodec', false, _('Allowed codec'), null, true), 12, 4); |
| 1204 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountMusicOnHold', false, _('Music on hold'), null, true), 12, 4); |
| 1205 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountExpirationTimestamp', false, _('Expiration timestamp'), null, true), 12, 4); |
| 1206 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountRegistrationContext', false, _('Registration context'), null, true), 12, 4); |
| 1207 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountRegistrationExten', false, _('Registration extension'), null, true), 12, 4); |
| 1208 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountCanCallForward', false, _('Can call forward'), null, true), 12, 4); |
| 1209 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountIPAddress', false, _('IP address'), null, true), 12, 4); |
| 1210 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountDefaultUser', false, _('Default user'), null, true), 12, 4); |
| 1211 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountRegistrationServer', false, _('Registration server'), null, true), 12, 4); |
| 1212 |
$configContainer->add(new htmlResponsiveInputCheckbox('asteriskAccount_hideAstAccountLastQualifyMilliseconds', false, _('Last qualify milliseconds'), null, true), 12, 4); |
| 1213 |
$configContainer->add(new htmlOutputText(''), 0, 4); |
| 1214 |
return $configContainer; |
| 1215 |
} |
| 1216 |
|
| 1217 |
/** |
| 1218 |
* @inheritDoc |
| 1219 |
*/ |
| 1220 |
public function supportsPasswordQuickChangePage(): bool { |
| 1221 |
return true; |
| 1222 |
} |
| 1223 |
|
| 1224 |
/** |
| 1225 |
* @inheritDoc |
| 1226 |
*/ |
| 1227 |
public function addPasswordQuickChangeAccountDetails(htmlResponsiveRow $row): void { |
| 1228 |
// no details |
| 1229 |
} |
| 1230 |
|
| 1231 |
/** |
| 1232 |
* @inheritDoc |
| 1233 |
*/ |
| 1234 |
public function getPasswordQuickChangeOptions(bool $forcePasswordChangeByDefault): array { |
| 1235 |
$options = []; |
| 1236 |
if (in_array_ignore_case('AsteriskSIPUser', $this->attributes['objectClass'])) { |
| 1237 |
$options[] = new PasswordQuickChangeOption('syncAsterisk', _('Change Asterisk password')); |
| 1238 |
} |
| 1239 |
return $options; |
| 1240 |
} |
| 1241 |
|
| 1242 |
/** |
| 1243 |
* @inheritDoc |
| 1244 |
*/ |
| 1245 |
public function getPasswordQuickChangeChanges(string $password): array { |
| 1246 |
$attrs = []; |
| 1247 |
if (isset($_POST['syncAsterisk'])) { |
| 1248 |
$attrs['AstAccountRealmedPassword'][0] = self::buildPasswordString($this->attributes, $this->moduleSettings, $password); |
| 1249 |
} |
| 1250 |
return $attrs; |
| 1251 |
} |
| 1252 |
|
| 1253 |
/** |
| 1254 |
* @inheritDoc |
| 1255 |
*/ |
| 1256 |
public function getPasswordQuickChangePasswordStrengthUserName(): ?string { |
| 1257 |
return null; |
| 1258 |
} |
| 1259 |
|
| 1260 |
/** |
| 1261 |
* @inheritDoc |
| 1262 |
*/ |
| 1263 |
public function getPasswordQuickChangePasswordStrengthAttributes(): array { |
| 1264 |
return []; |
| 1265 |
} |
| 1266 |
|
| 1267 |
/** |
| 1268 |
* @inheritDoc |
| 1269 |
*/ |
| 1270 |
public function getPasswordQuickChangeIsPasswordInHistory(string $password): bool { |
| 1271 |
return false; |
| 1272 |
} |
| 1273 |
|
| 1274 |
/** |
| 1275 |
* @inheritDoc |
| 1276 |
*/ |
| 1277 |
public function getListAttributeDescriptions(ConfiguredType $type): array { |
| 1278 |
return [ |
| 1279 |
'astaccountcallerid' => _('Caller ID'), |
| 1280 |
'astaccountcontext' => _('Account context'), |
| 1281 |
'astaccounthost' => _('Host'), |
| 1282 |
'astaccounttype' => _('Account type'), |
| 1283 |
'astaccountuseragent' => _('User agent'), |
| 1284 |
'astaccountamaflags' => _('AMA flags'), |
| 1285 |
'astaccountcallgroup' => _('Call groups'), |
| 1286 |
'astaccountdtmfmode' => _('DTFM flags'), |
| 1287 |
'astaccountfromuser' => _('From user'), |
| 1288 |
'astaccountfromdomain' => _('From domain'), |
| 1289 |
'astaccountfullcontact' => _('Full contact'), |
| 1290 |
'astaccountinsecure' => _('Insecure'), |
| 1291 |
'astaccountmailbox' => _('Mailbox'), |
| 1292 |
'astaccountnat' => _('NAT'), |
| 1293 |
'astaccountdeny' => _('Deny'), |
| 1294 |
'astaccountpermit' => _('Permit'), |
| 1295 |
'astaccountpickupgroup' => _('Pickup group'), |
| 1296 |
'astaccountport' => _('Port'), |
| 1297 |
'astaccountqualify' => _('Qualify'), |
| 1298 |
'astaccountrestrictcid' => _('Restrict caller ID'), |
| 1299 |
'astaccountrtptimeout' => _('RTP timeout'), |
| 1300 |
'astaccountrtpholdtimeout' => _('RTP hold timeout'), |
| 1301 |
'astaccountdisallowedcodec' => _('Disallowed codec'), |
| 1302 |
'astaccountallowedcodec' => _('Allowed codec'), |
| 1303 |
'astaccountmusiconhold' => _('Music on hold'), |
| 1304 |
'astaccountexpirationtimestamp' => _('Expiration timestamp'), |
| 1305 |
'astaccountregistrationcontext' => _('Registration context'), |
| 1306 |
'astaccountregistrationexten' => _('Registration extension'), |
| 1307 |
'astaccountcancallforward' => _('Can call forward'), |
| 1308 |
'astaccountipaddress' => _('IP address'), |
| 1309 |
'astaccountdefaultuser' => _('Default user'), |
| 1310 |
'astaccountregistrationserver' => _('Registration server'), |
| 1311 |
'astaccountlastqualifymilliseconds' => _('Last qualify milliseconds'), |
| 1312 |
]; |
| 1313 |
} |
| 1314 |
|
| 1315 |
} |