2009-11-21 15:25:05 +00:00
< ? php
/*
$Id $
This code is part of LDAP Account Manager ( http :// www . sourceforge . net / projects / lam )
2012-01-12 19:22:00 +00:00
Copyright ( C ) 2009 - 2012 Pavel Pozdnyak
2017-11-25 16:51:13 +00:00
2009 - 2017 Roland Gruber
2009-11-21 15:25:05 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
2009-12-16 18:45:26 +00:00
/**
* Manages the Asterisk extension of user accounts .
*
* @ package modules
*
* @ author Pavel Pozdnyak
* @ author Roland Gruber
*/
2009-11-21 15:25:05 +00:00
/**
2009-12-16 18:45:26 +00:00
* Manages the Asterisk extension of user accounts .
2009-11-21 15:25:05 +00:00
*
2009-12-16 18:56:51 +00:00
* @ package modules
2009-11-21 15:25:05 +00:00
*/
class asteriskAccount extends baseModule implements passwordService {
2010-04-07 19:24:27 +00:00
const ASTERISK_DEFAULT_REALM = " asterisk " ;
2010-03-17 17:48:42 +00:00
2009-11-21 15:25:05 +00:00
/**
* Creates a new asteriskAccount object .
*
* @ param string $scope account type ( user , group , host )
*/
function __construct ( $scope ) {
// call parent constructor
parent :: __construct ( $scope );
$this -> autoAddObjectClasses = false ;
}
2014-04-20 12:59:36 +00:00
/**
* Returns true if this module can manage accounts of the current type , otherwise false .
2017-02-19 08:14:11 +00:00
*
2014-04-20 12:59:36 +00:00
* @ return boolean true if module fits
*/
public function can_manage () {
return in_array ( $this -> get_scope (), array ( 'user' ));
}
2009-11-21 15:25:05 +00:00
/**
2010-06-12 17:17:31 +00:00
* Returns meta data that is interpreted by parent class .
2009-11-21 15:25:05 +00:00
*
* @ return array array with meta data
*/
function get_metaData () {
2017-02-19 08:14:11 +00:00
$return = array ();
2009-11-21 15:25:05 +00:00
$return [ " is_base " ] = false ;
// alias name
$return [ " alias " ] = _ ( " Asterisk " );
// module dependencies
2012-01-12 19:22:00 +00:00
$return [ 'dependencies' ] = array ( 'depends' => array (), 'conflicts' => array ());
2009-11-21 15:25:05 +00:00
// managed object classes
$return [ 'objectClasses' ] = array ( 'AsteriskSIPUser' );
// managed attributes
$return [ 'attributes' ] = array ( 'AstAccountCallerID' , 'AstAccountHost' ,
2011-03-21 20:50:45 +00:00
'AstAccountRealmedPassword' , 'AstAccountContext' , 'AstAccountType' ,
'AstAccountUserAgent' , 'AstAccountAMAFlags' , 'AstAccountCallGroup' ,
'AstAccountDTMFMode' , 'AstAccountFromUser' , 'AstAccountFromDomain' ,
'AstAccountFullContact' , 'AstAccountInsecure' , 'AstAccountMailbox' ,
'AstAccountNAT' , 'AstAccountDeny' , 'AstAccountPermit' ,
'AstAccountPickupGroup' , 'AstAccountPort' , 'AstAccountQualify' ,
'AstAccountRestrictCID' , 'AstAccountRTPTimeout' , 'AstAccountRTPHoldTimeout' ,
'AstAccountDisallowedCodec' , 'AstAccountAllowedCodec' , 'AstAccountMusicOnHold' ,
'AstAccountExpirationTimestamp' , 'AstAccountRegistrationContext' ,
'AstAccountRegistrationExten' , 'AstAccountCanCallForward' , 'AstAccountIPAddress' ,
'AstAccountDefaultUser' , 'AstAccountRegistrationServer' , 'AstAccountLastQualifyMilliseconds' ,
);
2009-11-21 15:25:05 +00:00
// icon
$return [ 'icon' ] = 'asterisk.png' ;
2010-09-02 18:21:59 +00:00
// self service
$return [ 'selfServiceFieldSettings' ] = array (
'syncAsteriskPassword' => _ ( 'Sync Asterisk password with Unix password' ),
);
2013-11-30 15:02:06 +00:00
// self service: fields that cannot be relabeled
$return [ 'selfServiceNoRelabelFields' ] = array ( 'syncAsteriskPassword' );
2009-11-21 15:25:05 +00:00
// help
$return [ 'help' ] = array (
'AstAccountCallerID' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Caller ID " ), 'attr' => 'AstAccountCallerID' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " This is the ID of the user in the Asterisk database. It may contain digits and letters (e.g. user1 or 200134). " )
2009-11-21 15:25:05 +00:00
),
'AstAccountHost' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Host " ), 'attr' => 'AstAccountHost' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " This is the machine id (e.g. IP address or host name) from which the user can call/receive calls. " )
2009-11-21 15:25:05 +00:00
),
'AstAccountContext' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Account context " ), 'attr' => 'AstAccountContext' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " The account context stores information about the dial plan. " )
2009-11-22 13:41:20 +00:00
),
'AstAccountRealmedPassword' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Password " ), 'attr' => 'AstAccountRealmedPassword' ,
2009-11-22 13:41:20 +00:00
" Text " => _ ( " Please enter the password which you want to set for this account. " )
),
2011-02-24 18:51:57 +00:00
'AstAccountType' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Account type " ), 'attr' => 'AstAccountType' ,
2011-02-24 18:51:57 +00:00
" Text " => _ ( " Please enter the account's type (e.g. \" friend \" ). " )
),
2010-03-17 17:48:42 +00:00
'AsteriskRealm' => array (
" Headline " => _ ( " Asterisk realm " ),
2010-04-02 11:39:09 +00:00
" Text " => _ ( " Authentication realm for Asterisk server (default: asterisk). This value set in sip.conf (option: \" realm \" ). " )
2010-03-17 17:48:42 +00:00
),
2011-03-21 20:50:45 +00:00
'AstAccountUserAgent' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " User agent " ), 'attr' => 'AstAccountUserAgent' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " SIP user agent identification. " )
),
'AstAccountAMAFlags' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " AMA flags " ), 'attr' => 'AstAccountAMAFlags' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Asterisk AMA (Automated Message Accounting) flags. " )
),
'AstAccountCallGroup' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Call groups " ), 'attr' => 'AstAccountCallGroup' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " The user's call groups. " )
2017-02-19 08:14:11 +00:00
),
2011-03-21 20:50:45 +00:00
'AstAccountDTMFMode' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " DTMF mode " ), 'attr' => 'AstAccountDTMFMode' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " DTMF mode for SIP client configuration. " )
),
'AstAccountFromUser' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " From user " ), 'attr' => 'AstAccountFromUser' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " From user setting for this account. " )
),
'AstAccountFromDomain' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " From domain " ), 'attr' => 'AstAccountFromDomain' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " From domain setting for this account. " )
),
'AstAccountFullContact' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Full contact " ), 'attr' => 'AstAccountFullContact' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " SIP URI for a realtime peer. " )
),
'AstAccountInsecure' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Insecure " ), 'attr' => 'AstAccountInsecure' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " This is typically used to allow incoming calls (e.g. from FWD) while having a type=friend entry defined with username and password. " )
),
'AstAccountMailbox' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Mailbox " ), 'attr' => 'AstAccountMailbox' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Defines the mailbox to check for message waiting indication (MWI) for this peer. " )
),
'AstAccountNAT' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " NAT " ), 'attr' => 'AstAccountNAT' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " NAT setting for this account. " )
),
'AstAccountDeny' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Deny " ), 'attr' => 'AstAccountDeny' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Used to limit SIP traffic to and from this peer to a certain IP or network. " )
),
'AstAccountPermit' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Permit " ), 'attr' => 'AstAccountPermit' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Used to limit SIP traffic to and from this peer to a certain IP or network. " )
),
'AstAccountPickupGroup' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Pickup group " ), 'attr' => 'AstAccountPickupGroup' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Specifies the user's pickup group. " )
),
'AstAccountPort' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Port " ), 'attr' => 'AstAccountPort' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Port number. " )
),
'AstAccountQualify' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Qualify " ), 'attr' => 'AstAccountQualify' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Used to regularly check that a device is still online. " )
),
'AstAccountRestrictCID' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Restrict caller ID " ), 'attr' => 'AstAccountRestrictCID' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Use this to hide the caller ID. " )
),
'AstAccountRTPTimeout' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " RTP timeout " ), 'attr' => 'AstAccountRTPTimeout' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Used to automatically hangup the call if no RTP traffic is received. " )
),
'AstAccountRTPHoldTimeout' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " RTP hold timeout " ), 'attr' => 'AstAccountRTPHoldTimeout' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Maximum number of seconds of inactivity before terminating a call on hold. " )
),
'AstAccountDisallowedCodec' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Disallowed codec " ), 'attr' => 'AstAccountDisallowedCodec' ,
2011-03-27 19:27:21 +00:00
" Text " => _ ( " List of disallowed codecs. " )
2011-03-21 20:50:45 +00:00
),
'AstAccountAllowedCodec' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Allowed codec " ), 'attr' => 'AstAccountAllowedCodec' ,
2011-03-27 19:27:21 +00:00
" Text " => _ ( " List of allowed codecs. " )
2011-03-21 20:50:45 +00:00
),
'AstAccountMusicOnHold' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Music on hold " ), 'attr' => 'AstAccountMusicOnHold' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Music to play on hold. " )
),
'AstAccountExpirationTimestamp' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Expiration timestamp " ), 'attr' => 'AstAccountExpirationTimestamp' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Expiration timestamp ( \" regseconds \" option). " )
),
'AstAccountRegistrationContext' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Registration context " ), 'attr' => 'AstAccountRegistrationContext' ,
2011-03-21 20:50:45 +00:00
" 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. " )
),
'AstAccountRegistrationExten' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Registration extension " ), 'attr' => 'AstAccountRegistrationExten' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Used for registration context. " )
),
'AstAccountCanCallForward' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Can call forward " ), 'attr' => 'AstAccountCanCallForward' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Specifies if the user can call forward. " )
),
'AstAccountIPAddress' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " IP address " ), 'attr' => 'AstAccountIPAddress' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " IP address of the peer. Valid only for realtime peers. " )
),
'AstAccountDefaultUser' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Default user " ), 'attr' => 'AstAccountDefaultUser' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " Authentication user for outbound proxies. " )
),
'AstAccountRegistrationServer' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Registration server " ), 'attr' => 'AstAccountRegistrationServer' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " IP address or domain name of the registration server. " )
),
'AstAccountLastQualifyMilliseconds' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Last qualify milliseconds " ), 'attr' => 'AstAccountLastQualifyMilliseconds' ,
2011-03-21 20:50:45 +00:00
" Text " => _ ( " The number of milliseconds for the last qualify. " )
),
2011-03-26 13:53:34 +00:00
'hiddenOptions' => array (
" Headline " => _ ( " Hidden options " ),
" Text " => _ ( " The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields. " )
),
2010-03-17 17:48:42 +00:00
);
2017-02-19 08:14:11 +00:00
// self service options
2010-09-14 18:25:36 +00:00
$selfServiceContainer = new htmlTable ();
2011-03-23 17:52:45 +00:00
$selfServiceContainer -> addElement ( new htmlTableExtendedInputField ( _ ( 'Asterisk realm' ), 'asteriskAccount_AsteriskRealm' , null ));
$selfServiceContainer -> addElement ( new htmlHelpLink ( 'AsteriskRealm' , get_class ( $this )));
2010-09-14 18:25:36 +00:00
$return [ 'selfServiceSettings' ] = $selfServiceContainer ;
2009-11-21 15:25:05 +00:00
// profile options
2010-09-14 18:25:36 +00:00
$profileContainer = new htmlTable ();
$profileContainer -> addElement ( new htmlTableExtendedInputField ( _ ( 'Host' ), 'asteriskAccount_AstAccountHost' , null , 'AstAccountHost' ), true );
$profileContainer -> addElement ( new htmlTableExtendedInputField ( _ ( 'Account context' ), 'asteriskAccount_AstAccountContext' , null , 'AstAccountContext' ), true );
2011-02-24 18:51:57 +00:00
$profileContainer -> addElement ( new htmlTableExtendedInputField ( _ ( 'Account type' ), 'asteriskAccount_AstAccountType' , null , 'AstAccountType' ), true );
2010-09-14 18:25:36 +00:00
$return [ 'profile_options' ] = $profileContainer ;
2009-11-21 15:25:05 +00:00
// profile mappings
$return [ 'profile_mappings' ] = array (
'asteriskAccount_AstAccountHost' => 'AstAccountHost' ,
2011-02-24 18:51:57 +00:00
'asteriskAccount_AstAccountContext' => 'AstAccountContext' ,
'asteriskAccount_AstAccountType' => 'AstAccountType' ,
2009-11-21 15:25:05 +00:00
);
2009-11-22 13:41:20 +00:00
// available PDF fields
$return [ 'PDF_fields' ] = array (
2010-04-05 12:38:23 +00:00
'AstAccountCallerID' => _ ( 'Caller ID' ),
'AstAccountContext' => _ ( 'Account context' ),
'AstAccountHost' => _ ( 'Host' ),
2011-02-24 18:51:57 +00:00
'AstAccountType' => _ ( 'Account type' ),
2011-03-21 20:50:45 +00:00
'AstAccountUserAgent' => _ ( 'User agent' ),
'AstAccountAMAFlags' => _ ( 'AMA flags' ),
'AstAccountCallGroup' => _ ( 'Call groups' ),
'AstAccountDTMFMode' => _ ( 'DTFM flags' ),
'AstAccountFromUser' => _ ( 'From user' ),
'AstAccountFromDomain' => _ ( 'From domain' ),
'AstAccountFullContact' => _ ( 'Full contact' ),
'AstAccountInsecure' => _ ( 'Insecure' ),
'AstAccountMailbox' => _ ( 'Mailbox' ),
'AstAccountNAT' => _ ( 'NAT' ),
'AstAccountDeny' => _ ( 'Deny' ),
'AstAccountPermit' => _ ( 'Permit' ),
'AstAccountPickupGroup' => _ ( 'Pickup group' ),
'AstAccountPort' => _ ( 'Port' ),
'AstAccountQualify' => _ ( 'Qualify' ),
'AstAccountRestrictCID' => _ ( 'Restrict caller ID' ),
'AstAccountRTPTimeout' => _ ( 'RTP timeout' ),
'AstAccountRTPHoldTimeout' => _ ( 'RTP hold timeout' ),
'AstAccountDisallowedCodec' => _ ( 'Disallowed codec' ),
'AstAccountAllowedCodec' => _ ( 'Allowed codec' ),
'AstAccountMusicOnHold' => _ ( 'Music on hold' ),
'AstAccountExpirationTimestamp' => _ ( 'Expiration timestamp' ),
'AstAccountRegistrationContext' => _ ( 'Registration context' ),
2011-04-09 13:11:38 +00:00
'AstAccountRegistrationExten' => _ ( 'Registration extension' ),
2011-03-21 20:50:45 +00:00
'AstAccountCanCallForward' => _ ( 'Can call forward' ),
'AstAccountIPAddress' => _ ( 'IP address' ),
'AstAccountDefaultUser' => _ ( 'Default user' ),
'AstAccountRegistrationServer' => _ ( 'Registration server' ),
'AstAccountLastQualifyMilliseconds' => _ ( 'Last qualify milliseconds' ),
2009-11-22 13:41:20 +00:00
);
// upload fields
$return [ 'upload_columns' ] = array (
array (
'name' => 'asteriskAccount_AstAccountCallerID' ,
'description' => _ ( 'Caller ID' ),
'help' => 'AstAccountCallerID' ,
'example' => '12345' ,
'required' => true
),
array (
'name' => 'asteriskAccount_AstAccountContext' ,
'description' => _ ( 'Account context' ),
'help' => 'AstAccountContext' ,
2009-12-08 21:29:19 +00:00
'example' => 'default' ,
2009-11-22 13:41:20 +00:00
'required' => true
),
array (
'name' => 'asteriskAccount_AstAccountHost' ,
'description' => _ ( 'Host' ),
'help' => 'AstAccountHost' ,
'example' => 'dynamic' ,
'default' => 'dynamic' ,
),
array (
'name' => 'asteriskAccount_AstAccountRealmedPassword' ,
'description' => _ ( 'Password' ),
'help' => 'AstAccountRealmedPassword' ,
'example' => _ ( 'secret' ),
),
2011-02-24 18:51:57 +00:00
array (
'name' => 'asteriskAccount_AstAccountType' ,
'description' => _ ( 'Account type' ),
'help' => 'AstAccountType' ,
'example' => 'friend' ,
'required' => true
),
2009-11-22 13:41:20 +00:00
);
2011-03-29 19:46:58 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountUserAgent' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountUserAgent' ,
'description' => _ ( 'User agent' ),
'help' => 'AstAccountUserAgent' ,
);
}
2011-03-31 18:48:15 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountAMAFlags' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountAMAFlags' ,
'description' => _ ( 'AMA flags' ),
'help' => 'AstAccountAMAFlags' ,
'example' => 'billing' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountCallGroup' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountCallGroup' ,
'description' => _ ( 'Call groups' ),
'help' => 'AstAccountCallGroup' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDTMFMode' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountDTMFMode' ,
'description' => _ ( 'DTFM flags' ),
'help' => 'AstAccountDTMFMode' ,
'example' => 'auto' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFromUser' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountFromUser' ,
'description' => _ ( 'From user' ),
'help' => 'AstAccountFromUser' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFromDomain' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountFromDomain' ,
'description' => _ ( 'From domain' ),
'help' => 'AstAccountFromDomain' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFullContact' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountFullContact' ,
'description' => _ ( 'Full contact' ),
'help' => 'AstAccountFullContact' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountInsecure' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountInsecure' ,
'description' => _ ( 'Insecure' ),
'help' => 'AstAccountInsecure' ,
'example' => 'invite' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountMailbox' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountMailbox' ,
'description' => _ ( 'Mailbox' ),
'help' => 'AstAccountMailbox' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountNAT' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountNAT' ,
'description' => _ ( 'NAT' ),
'help' => 'AstAccountNAT' ,
'example' => 'never' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDeny' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountDeny' ,
'description' => _ ( 'Deny' ),
'help' => 'AstAccountDeny' ,
);
}
2017-02-19 08:14:11 +00:00
2011-03-31 18:48:15 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPermit' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountPermit' ,
'description' => _ ( 'Permit' ),
'help' => 'AstAccountPermit' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPickupGroup' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountPickupGroup' ,
'description' => _ ( 'Pickup group' ),
'help' => 'AstAccountPickupGroup' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPort' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountPort' ,
'description' => _ ( 'Port' ),
'help' => 'AstAccountPort' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountQualify' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountQualify' ,
'description' => _ ( 'Qualify' ),
'help' => 'AstAccountQualify' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRestrictCID' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountRestrictCID' ,
'description' => _ ( 'Restrict caller ID' ),
'help' => 'AstAccountRestrictCID' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRTPTimeout' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountRTPTimeout' ,
'description' => _ ( 'RTP timeout' ),
'help' => 'AstAccountRTPTimeout' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRTPHoldTimeout' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountRTPHoldTimeout' ,
'description' => _ ( 'RTP hold timeout' ),
'help' => 'AstAccountRTPHoldTimeout' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDisallowedCodec' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountDisallowedCodec' ,
'description' => _ ( 'Disallowed codec' ),
'help' => 'AstAccountDisallowedCodec' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountAllowedCodec' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountAllowedCodec' ,
'description' => _ ( 'Allowed codec' ),
'help' => 'AstAccountAllowedCodec' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountMusicOnHold' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountMusicOnHold' ,
'description' => _ ( 'Music on hold' ),
'help' => 'AstAccountMusicOnHold' ,
);
}
2017-02-19 08:14:11 +00:00
2011-03-31 18:48:15 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountExpirationTimestamp' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountExpirationTimestamp' ,
'description' => _ ( 'Expiration timestamp' ),
'help' => 'AstAccountExpirationTimestamp' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationContext' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountRegistrationContext' ,
'description' => _ ( 'Registration context' ),
'help' => 'AstAccountRegistrationContext' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationExten' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountRegistrationExten' ,
2011-04-09 13:11:38 +00:00
'description' => _ ( 'Registration extension' ),
2011-03-31 18:48:15 +00:00
'help' => 'AstAccountRegistrationExten' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountCanCallForward' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountCanCallForward' ,
'description' => _ ( 'Can call forward' ),
'help' => 'AstAccountCanCallForward' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountIPAddress' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountIPAddress' ,
'description' => _ ( 'IP address' ),
'help' => 'AstAccountIPAddress' ,
);
}
2017-02-19 08:14:11 +00:00
2011-03-31 18:48:15 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDefaultUser' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountDefaultUser' ,
'description' => _ ( 'Default user' ),
'help' => 'AstAccountDefaultUser' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationServer' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountRegistrationServer' ,
'description' => _ ( 'Registration server' ),
'help' => 'AstAccountRegistrationServer' ,
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountLastQualifyMilliseconds' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'asteriskAccount_AstAccountLastQualifyMilliseconds' ,
'description' => _ ( 'Last qualify milliseconds' ),
'help' => 'AstAccountLastQualifyMilliseconds' ,
);
}
2009-11-21 15:25:05 +00:00
return $return ;
}
/**
* This function fills the error message array with messages
*/
function load_Messages () {
$this -> messages [ 'AstAccountCallerID' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter a caller ID.' ));
$this -> messages [ 'AstAccountCallerID' ][ 1 ] = array ( 'ERROR' , _ ( 'The caller ID format is invalid.' ));
$this -> messages [ 'AstAccountCallerID' ][ 2 ] = array ( 'ERROR' , _ ( 'There is already another user with this caller ID.' ));
2009-11-22 13:41:20 +00:00
$this -> messages [ 'AstAccountCallerID' ][ 3 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountCallerID' , _ ( 'The caller ID format is invalid.' ));
2009-11-21 15:25:05 +00:00
$this -> messages [ 'AstAccountContext' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter the extension context.' ));
2009-11-22 13:41:20 +00:00
$this -> messages [ 'AstAccountContext' ][ 1 ] = array ( 'ERROR' , _ ( 'The extension context is invalid.' ));
$this -> messages [ 'AstAccountContext' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountContext' , _ ( 'The extension context is invalid.' ));
2009-11-21 15:25:05 +00:00
$this -> messages [ 'AstAccountHost' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter the host name.' ));
2009-11-22 13:41:20 +00:00
$this -> messages [ 'AstAccountHost' ][ 1 ] = array ( 'ERROR' , _ ( 'The host name is invalid.' ));
$this -> messages [ 'AstAccountHost' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountHost' , _ ( 'The host name is invalid.' ));
2011-02-24 18:51:57 +00:00
$this -> messages [ 'AstAccountType' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter the account type.' ));
$this -> messages [ 'AstAccountType' ][ 1 ] = array ( 'ERROR' , _ ( 'The account type is invalid.' ));
$this -> messages [ 'AstAccountType' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountType' , _ ( 'The account type is invalid.' ));
2011-03-29 19:46:58 +00:00
$this -> messages [ 'AstAccountFromUser' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter a valid from user.' ));
$this -> messages [ 'AstAccountFromUser' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountFromUser' , _ ( 'Please enter a valid from user.' ));
$this -> messages [ 'AstAccountFromDomain' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter a valid from domain.' ));
$this -> messages [ 'AstAccountFromDomain' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountFromDomain' , _ ( 'Please enter a valid from domain.' ));
$this -> messages [ 'AstAccountPort' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter a valid port number.' ));
$this -> messages [ 'AstAccountPort' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountPort' , _ ( 'Please enter a valid port number.' ));
$this -> messages [ 'AstAccountIPAddress' ][ 0 ] = array ( 'ERROR' , _ ( 'The IP address is invalid.' ));
$this -> messages [ 'AstAccountIPAddress' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountIPAddress' , _ ( 'The IP address is invalid.' ));
$this -> messages [ 'AstAccountDefaultUser' ][ 0 ] = array ( 'ERROR' , _ ( 'Please enter a valid default user.' ));
$this -> messages [ 'AstAccountDefaultUser' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' asteriskAccount_AstAccountDefaultUser' , _ ( 'Please enter a valid default user.' ));
2009-11-21 15:25:05 +00:00
}
/**
2010-09-18 11:37:22 +00:00
* Returns the HTML meta data for the main account page .
2017-02-19 08:14:11 +00:00
*
2010-09-18 11:37:22 +00:00
* @ return htmlElement HTML meta data
2009-11-21 15:25:05 +00:00
*/
function display_html_attributes () {
2010-09-14 18:25:36 +00:00
$return = new htmlTable ();
2009-11-21 15:25:05 +00:00
if ( in_array ( 'AsteriskSIPUser' , $this -> attributes [ 'objectClass' ])) {
2010-09-14 18:25:36 +00:00
// caller ID
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountCallerID' , _ ( " Caller ID " ), true );
2010-09-14 18:25:36 +00:00
// host
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountHost' , _ ( " Host " ), true );
2010-09-14 18:25:36 +00:00
// context
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountContext' , _ ( " Account context " ), true );
2011-02-24 18:51:57 +00:00
// account type
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountType' , _ ( " Account type " ), true );
2011-03-27 19:27:21 +00:00
// user agent
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountUserAgent' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountUserAgent' , _ ( " User agent " ));
2011-03-27 19:27:21 +00:00
}
// AMA flags
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountAMAFlags' )) {
$AstAccountAMAFlagsOptions = array ( '-' , 'default' , 'omit' , 'billing' , 'documentation' );
$AstAccountAMAFlags = array ();
if ( isset ( $this -> attributes [ 'AstAccountAMAFlags' ][ 0 ])) {
$AstAccountAMAFlags [] = $this -> attributes [ 'AstAccountAMAFlags' ][ 0 ];
if (( $this -> attributes [ 'AstAccountAMAFlags' ][ 0 ] != '' ) && ! in_array ( $this -> attributes [ 'AstAccountAMAFlags' ][ 0 ], $AstAccountAMAFlagsOptions )) {
$AstAccountAMAFlagsOptions [] = $this -> attributes [ 'AstAccountAMAFlags' ][ 0 ];
}
}
$AstAccountAMAFlagsInput = new htmlTableExtendedSelect ( 'AstAccountAMAFlags' , $AstAccountAMAFlagsOptions , $AstAccountAMAFlags , _ ( " AMA flags " ), 'AstAccountAMAFlags' );
$return -> addElement ( $AstAccountAMAFlagsInput , true );
}
// call groups
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountCallGroup' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountCallGroup' , _ ( " Call groups " ));
2011-03-27 19:27:21 +00:00
}
// DTMF flags
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDTMFMode' )) {
$AstAccountDTMFModeOptions = array ( '-' , 'inband' , 'rfc2833' , 'info' , 'auto' );
$AstAccountDTMFMode = array ();
if ( isset ( $this -> attributes [ 'AstAccountDTMFMode' ][ 0 ])) {
$AstAccountDTMFMode [] = $this -> attributes [ 'AstAccountDTMFMode' ][ 0 ];
if (( $this -> attributes [ 'AstAccountDTMFMode' ][ 0 ] != '' ) && ! in_array ( $this -> attributes [ 'AstAccountDTMFMode' ][ 0 ], $AstAccountDTMFModeOptions )) {
$AstAccountDTMFModeOptions [] = $this -> attributes [ 'AstAccountDTMFMode' ][ 0 ];
}
}
$AstAccountDTMFModeInput = new htmlTableExtendedSelect ( 'AstAccountDTMFMode' , $AstAccountDTMFModeOptions , $AstAccountDTMFMode , _ ( " DTFM flags " ), 'AstAccountDTMFMode' );
$return -> addElement ( $AstAccountDTMFModeInput , true );
}
// from user
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFromUser' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountFromUser' , _ ( " From user " ));
2011-03-27 19:27:21 +00:00
}
// from domain
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFromDomain' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountFromDomain' , _ ( " From domain " ));
2011-03-27 19:27:21 +00:00
}
// full contact
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFullContact' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountFullContact' , _ ( " Full contact " ));
2011-03-27 19:27:21 +00:00
}
// insecure
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountInsecure' )) {
$AstAccountInsecureOptions = array ( '-' , 'port' , 'invite' , 'port,invite' );
$AstAccountInsecure = array ();
if ( isset ( $this -> attributes [ 'AstAccountInsecure' ][ 0 ])) {
$AstAccountInsecure [] = $this -> attributes [ 'AstAccountInsecure' ][ 0 ];
if (( $this -> attributes [ 'AstAccountInsecure' ][ 0 ] != '' ) && ! in_array ( $this -> attributes [ 'AstAccountInsecure' ][ 0 ], $AstAccountInsecureOptions )) {
$AstAccountInsecureOptions [] = $this -> attributes [ 'AstAccountInsecure' ][ 0 ];
}
}
$AstAccountInsecureInput = new htmlTableExtendedSelect ( 'AstAccountInsecure' , $AstAccountInsecureOptions , $AstAccountInsecure , _ ( " Insecure " ), 'AstAccountInsecure' );
$return -> addElement ( $AstAccountInsecureInput , true );
}
// mailbox
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountMailbox' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountMailbox' , _ ( " Mailbox " ));
2011-03-27 19:27:21 +00:00
}
// NAT
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountNAT' )) {
$AstAccountNATOptions = array ( '-' , 'yes' , 'no' , 'never' , 'route' );
$AstAccountNAT = array ();
if ( isset ( $this -> attributes [ 'AstAccountNAT' ][ 0 ])) {
$AstAccountNAT [] = $this -> attributes [ 'AstAccountNAT' ][ 0 ];
if (( $this -> attributes [ 'AstAccountNAT' ][ 0 ] != '' ) && ! in_array ( $this -> attributes [ 'AstAccountNAT' ][ 0 ], $AstAccountNATOptions )) {
$AstAccountNATOptions [] = $this -> attributes [ 'AstAccountNAT' ][ 0 ];
}
}
$AstAccountNATInput = new htmlTableExtendedSelect ( 'AstAccountNAT' , $AstAccountNATOptions , $AstAccountNAT , _ ( " NAT " ), 'AstAccountNAT' );
$return -> addElement ( $AstAccountNATInput , true );
}
// deny
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDeny' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountDeny' , _ ( " Deny " ));
2011-03-27 19:27:21 +00:00
}
// permit
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPermit' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountPermit' , _ ( " Permit " ));
2011-03-27 19:27:21 +00:00
}
// pickup group
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPickupGroup' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountPickupGroup' , _ ( " Pickup group " ));
2011-03-27 19:27:21 +00:00
}
// port
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPort' )) {
2013-10-19 10:25:39 +00:00
$AstAccountPort = $this -> addSimpleInputTextField ( $return , 'AstAccountPort' , _ ( " Port " ));
$AstAccountPort -> setValidationRule ( htmlElement :: VALIDATE_NUMERIC );
2011-03-27 19:27:21 +00:00
}
// qualify
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountQualify' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountQualify' , _ ( " Qualify " ));
2011-03-27 19:27:21 +00:00
}
// restrict caller ID
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRestrictCID' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountRestrictCID' , _ ( " Restrict caller ID " ));
2011-03-27 19:27:21 +00:00
}
// RTP timeout
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRTPTimeout' )) {
2013-10-19 10:25:39 +00:00
$AstAccountRTPTimeout = $this -> addSimpleInputTextField ( $return , 'AstAccountRTPTimeout' , _ ( " RTP timeout " ));
$AstAccountRTPTimeout -> setValidationRule ( htmlElement :: VALIDATE_NUMERIC );
2011-03-27 19:27:21 +00:00
}
// RTP hold timeout
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRTPHoldTimeout' )) {
2013-10-19 10:25:39 +00:00
$AstAccountRTPHoldTimeoutInput = $this -> addSimpleInputTextField ( $return , 'AstAccountRTPHoldTimeout' , _ ( " RTP hold timeout " ));
2011-10-19 17:57:57 +00:00
$AstAccountRTPHoldTimeoutInput -> setValidationRule ( htmlElement :: VALIDATE_NUMERIC );
2011-03-27 19:27:21 +00:00
}
// disallowed codec
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDisallowedCodec' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountDisallowedCodec' , _ ( " Disallowed codec " ));
2011-03-27 19:27:21 +00:00
}
// allowed codec
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountAllowedCodec' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountAllowedCodec' , _ ( " Allowed codec " ));
2011-03-27 19:27:21 +00:00
}
// music on hold
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountMusicOnHold' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountMusicOnHold' , _ ( " Music on hold " ));
2011-03-27 19:27:21 +00:00
}
// expiration timestamp
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountExpirationTimestamp' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountExpirationTimestamp' , _ ( " Expiration timestamp " ));
2011-03-27 19:27:21 +00:00
}
// registration context
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationContext' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountRegistrationContext' , _ ( " Registration context " ));
2011-03-27 19:27:21 +00:00
}
// registration extension
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationExten' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountRegistrationExten' , _ ( " Registration extension " ));
2011-03-27 19:27:21 +00:00
}
// can call forward
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountCanCallForward' )) {
$AstAccountCanCallForwardOptions = array ( '-' , 'yes' , 'no' );
$AstAccountCanCallForward = array ();
if ( isset ( $this -> attributes [ 'AstAccountCanCallForward' ][ 0 ])) {
$AstAccountCanCallForward [] = $this -> attributes [ 'AstAccountCanCallForward' ][ 0 ];
if (( $this -> attributes [ 'AstAccountCanCallForward' ][ 0 ] != '' ) && ! in_array ( $this -> attributes [ 'AstAccountCanCallForward' ][ 0 ], $AstAccountCanCallForwardOptions )) {
$AstAccountCanCallForwardOptions [] = $this -> attributes [ 'AstAccountCanCallForward' ][ 0 ];
}
}
$AstAccountCanCallForwardInput = new htmlTableExtendedSelect ( 'AstAccountCanCallForward' , $AstAccountCanCallForwardOptions , $AstAccountCanCallForward , _ ( " Can call forward " ), 'AstAccountCanCallForward' );
$return -> addElement ( $AstAccountCanCallForwardInput , true );
}
// IP address
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountIPAddress' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountIPAddress' , _ ( " IP address " ));
2011-03-27 19:27:21 +00:00
}
// default user
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDefaultUser' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountDefaultUser' , _ ( " Default user " ));
2011-03-27 19:27:21 +00:00
}
// registration server
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationServer' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountRegistrationServer' , _ ( " Registration server " ));
2011-03-27 19:27:21 +00:00
}
// last qualify milliseconds
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountLastQualifyMilliseconds' )) {
2013-10-19 10:25:39 +00:00
$this -> addSimpleInputTextField ( $return , 'AstAccountLastQualifyMilliseconds' , _ ( " Last qualify milliseconds " ));
2011-03-27 19:27:21 +00:00
}
2010-09-14 18:25:36 +00:00
}
else {
$return -> addElement ( new htmlButton ( 'addObjectClass' , _ ( 'Add Asterisk account' )));
2009-11-21 15:25:05 +00:00
}
return $return ;
}
/**
* Write variables into object and do some regex checks
*/
function process_attributes () {
2012-02-16 07:30:15 +00:00
if ( isset ( $_POST [ 'addObjectClass' ])) {
$this -> attributes [ 'objectClass' ][] = 'AsteriskSIPUser' ;
return array ();
}
2009-11-21 15:25:05 +00:00
if ( ! in_array ( 'AsteriskSIPUser' , $this -> attributes [ 'objectClass' ])) {
return array ();
}
$errors = array ();
$this -> attributes [ 'AstAccountCallerID' ] = array ();
$this -> attributes [ 'AstAccountHost' ] = array ();
$this -> attributes [ 'AstAccountContext' ] = array ();
2011-02-24 18:51:57 +00:00
$this -> attributes [ 'AstAccountType' ] = array ();
2009-11-21 15:25:05 +00:00
if ( isset ( $_POST [ 'AstAccountCallerID' ])) {
$this -> attributes [ 'AstAccountCallerID' ][ 0 ] = $_POST [ 'AstAccountCallerID' ];
2009-11-22 13:41:20 +00:00
// check if caller ID is empty
2009-11-21 15:25:05 +00:00
if ( $this -> attributes [ 'AstAccountCallerID' ][ 0 ] == '' ) {
$errors [] = $this -> messages [ 'AstAccountCallerID' ][ 0 ];
}
2009-11-22 13:41:20 +00:00
// check format
else if ( ! get_preg ( $this -> attributes [ 'AstAccountCallerID' ][ 0 ], 'username' )) {
$errors [] = $this -> messages [ 'AstAccountCallerID' ][ 1 ];
}
// check for duplicate caller ID
else if ( ! isset ( $this -> orig [ 'AstAccountCallerID' ][ 0 ]) || (( $this -> orig [ 'AstAccountCallerID' ][ 0 ] != $this -> attributes [ 'AstAccountCallerID' ][ 0 ]))) {
2010-02-06 13:38:13 +00:00
$entries = searchLDAPByAttribute ( 'AstAccountCallerID' , $this -> attributes [ 'AstAccountCallerID' ][ 0 ], 'AsteriskSIPUser' , array ( 'dn' ), array ( 'user' ));
if ( sizeof ( $entries ) > 0 ) {
2009-11-21 15:25:05 +00:00
$errors [] = $this -> messages [ 'AstAccountCallerID' ][ 2 ];
}
}
}
if ( isset ( $_POST [ 'AstAccountHost' ])) {
$this -> attributes [ 'AstAccountHost' ][ 0 ] = $_POST [ 'AstAccountHost' ];
if ( $this -> attributes [ 'AstAccountHost' ][ 0 ] == '' ) {
$errors [] = $this -> messages [ 'AstAccountHost' ][ 0 ];
}
2009-11-22 13:41:20 +00:00
elseif ( ! get_preg ( $this -> attributes [ 'AstAccountHost' ][ 0 ], 'hostname' )) {
$errors [] = $this -> messages [ 'AstAccountHost' ][ 1 ];
}
2009-11-21 15:25:05 +00:00
}
if ( isset ( $_POST [ 'AstAccountContext' ])) {
$this -> attributes [ 'AstAccountContext' ][ 0 ] = $_POST [ 'AstAccountContext' ];
if ( $this -> attributes [ 'AstAccountContext' ][ 0 ] == '' ) {
$errors [] = $this -> messages [ 'AstAccountContext' ][ 0 ];
}
2009-11-22 13:41:20 +00:00
elseif ( ! get_preg ( $this -> attributes [ 'AstAccountContext' ][ 0 ], 'username' )) {
$errors [] = $this -> messages [ 'AstAccountContext' ][ 1 ];
}
2009-11-21 15:25:05 +00:00
}
2011-02-24 18:51:57 +00:00
if ( isset ( $_POST [ 'AstAccountType' ])) {
$this -> attributes [ 'AstAccountType' ][ 0 ] = $_POST [ 'AstAccountType' ];
if ( $this -> attributes [ 'AstAccountType' ][ 0 ] == '' ) {
$errors [] = $this -> messages [ 'AstAccountType' ][ 0 ];
}
elseif ( ! get_preg ( $this -> attributes [ 'AstAccountType' ][ 0 ], 'username' )) {
$errors [] = $this -> messages [ 'AstAccountType' ][ 1 ];
}
}
2011-03-28 19:57:22 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountUserAgent' )) {
$this -> attributes [ 'AstAccountUserAgent' ][ 0 ] = $_POST [ 'AstAccountUserAgent' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountAMAFlags' )) {
if (( $_POST [ 'AstAccountAMAFlags' ] == '-' ) && isset ( $this -> attributes [ 'AstAccountAMAFlags' ][ 0 ])) {
unset ( $this -> attributes [ 'AstAccountAMAFlags' ][ 0 ]);
}
else {
$this -> attributes [ 'AstAccountAMAFlags' ][ 0 ] = $_POST [ 'AstAccountAMAFlags' ];
}
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountCallGroup' )) {
$this -> attributes [ 'AstAccountCallGroup' ][ 0 ] = $_POST [ 'AstAccountCallGroup' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDTMFMode' )) {
if (( $_POST [ 'AstAccountDTMFMode' ] == '-' ) && isset ( $this -> attributes [ 'AstAccountDTMFMode' ][ 0 ])) {
unset ( $this -> attributes [ 'AstAccountDTMFMode' ][ 0 ]);
}
else {
$this -> attributes [ 'AstAccountDTMFMode' ][ 0 ] = $_POST [ 'AstAccountDTMFMode' ];
}
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFromUser' )) {
$this -> attributes [ 'AstAccountFromUser' ][ 0 ] = $_POST [ 'AstAccountFromUser' ];
2011-03-29 19:46:58 +00:00
if (( $_POST [ 'AstAccountFromUser' ] != '' ) && ! get_preg ( $_POST [ 'AstAccountFromUser' ], 'username' )) {
$errors [] = $this -> messages [ 'AstAccountFromUser' ][ 0 ];
}
2011-03-28 19:57:22 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFromDomain' )) {
$this -> attributes [ 'AstAccountFromDomain' ][ 0 ] = $_POST [ 'AstAccountFromDomain' ];
2011-03-29 19:46:58 +00:00
if (( $_POST [ 'AstAccountFromDomain' ] != '' ) && ! get_preg ( $_POST [ 'AstAccountFromDomain' ], 'domainname' )) {
$errors [] = $this -> messages [ 'AstAccountFromDomain' ][ 0 ];
}
2011-03-28 19:57:22 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountFullContact' )) {
$this -> attributes [ 'AstAccountFullContact' ][ 0 ] = $_POST [ 'AstAccountFullContact' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountInsecure' )) {
if (( $_POST [ 'AstAccountInsecure' ] == '-' ) && isset ( $this -> attributes [ 'AstAccountInsecure' ][ 0 ])) {
unset ( $this -> attributes [ 'AstAccountInsecure' ][ 0 ]);
}
else {
$this -> attributes [ 'AstAccountInsecure' ][ 0 ] = $_POST [ 'AstAccountInsecure' ];
}
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountMailbox' )) {
$this -> attributes [ 'AstAccountMailbox' ][ 0 ] = $_POST [ 'AstAccountMailbox' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountNAT' )) {
if (( $_POST [ 'AstAccountNAT' ] == '-' ) && isset ( $this -> attributes [ 'AstAccountNAT' ][ 0 ])) {
unset ( $this -> attributes [ 'AstAccountNAT' ][ 0 ]);
}
else {
$this -> attributes [ 'AstAccountNAT' ][ 0 ] = $_POST [ 'AstAccountNAT' ];
}
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDeny' )) {
$this -> attributes [ 'AstAccountDeny' ][ 0 ] = $_POST [ 'AstAccountDeny' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPermit' )) {
$this -> attributes [ 'AstAccountPermit' ][ 0 ] = $_POST [ 'AstAccountPermit' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPickupGroup' )) {
$this -> attributes [ 'AstAccountPickupGroup' ][ 0 ] = $_POST [ 'AstAccountPickupGroup' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountPort' )) {
$this -> attributes [ 'AstAccountPort' ][ 0 ] = $_POST [ 'AstAccountPort' ];
2011-03-29 19:46:58 +00:00
if (( $_POST [ 'AstAccountPort' ] != '' ) && ! get_preg ( $_POST [ 'AstAccountPort' ], 'digit' )) {
$errors [] = $this -> messages [ 'AstAccountPort' ][ 0 ];
}
2011-03-28 19:57:22 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountQualify' )) {
$this -> attributes [ 'AstAccountQualify' ][ 0 ] = $_POST [ 'AstAccountQualify' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRestrictCID' )) {
$this -> attributes [ 'AstAccountRestrictCID' ][ 0 ] = $_POST [ 'AstAccountRestrictCID' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRTPTimeout' )) {
$this -> attributes [ 'AstAccountRTPTimeout' ][ 0 ] = $_POST [ 'AstAccountRTPTimeout' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRTPHoldTimeout' )) {
$this -> attributes [ 'AstAccountRTPHoldTimeout' ][ 0 ] = $_POST [ 'AstAccountRTPHoldTimeout' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDisallowedCodec' )) {
$this -> attributes [ 'AstAccountDisallowedCodec' ][ 0 ] = $_POST [ 'AstAccountDisallowedCodec' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountAllowedCodec' )) {
$this -> attributes [ 'AstAccountAllowedCodec' ][ 0 ] = $_POST [ 'AstAccountAllowedCodec' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountMusicOnHold' )) {
$this -> attributes [ 'AstAccountMusicOnHold' ][ 0 ] = $_POST [ 'AstAccountMusicOnHold' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountExpirationTimestamp' )) {
$this -> attributes [ 'AstAccountExpirationTimestamp' ][ 0 ] = $_POST [ 'AstAccountExpirationTimestamp' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationContext' )) {
$this -> attributes [ 'AstAccountRegistrationContext' ][ 0 ] = $_POST [ 'AstAccountRegistrationContext' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationExten' )) {
$this -> attributes [ 'AstAccountRegistrationExten' ][ 0 ] = $_POST [ 'AstAccountRegistrationExten' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountCanCallForward' )) {
if (( $_POST [ 'AstAccountCanCallForward' ] == '-' ) && isset ( $this -> attributes [ 'AstAccountCanCallForward' ][ 0 ])) {
unset ( $this -> attributes [ 'AstAccountCanCallForward' ][ 0 ]);
}
else {
$this -> attributes [ 'AstAccountCanCallForward' ][ 0 ] = $_POST [ 'AstAccountCanCallForward' ];
}
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountIPAddress' )) {
$this -> attributes [ 'AstAccountIPAddress' ][ 0 ] = $_POST [ 'AstAccountIPAddress' ];
2011-03-29 19:46:58 +00:00
if (( $_POST [ 'AstAccountIPAddress' ] != '' ) && ! get_preg ( $_POST [ 'AstAccountIPAddress' ], 'ip' )) {
$errors [] = $this -> messages [ 'AstAccountIPAddress' ][ 0 ];
}
2011-03-28 19:57:22 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountDefaultUser' )) {
$this -> attributes [ 'AstAccountDefaultUser' ][ 0 ] = $_POST [ 'AstAccountDefaultUser' ];
2011-03-29 19:46:58 +00:00
if (( $_POST [ 'AstAccountDefaultUser' ] != '' ) && ! get_preg ( $_POST [ 'AstAccountDefaultUser' ], 'username' )) {
$errors [] = $this -> messages [ 'AstAccountDefaultUser' ][ 0 ];
}
2011-03-28 19:57:22 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountRegistrationServer' )) {
$this -> attributes [ 'AstAccountRegistrationServer' ][ 0 ] = $_POST [ 'AstAccountRegistrationServer' ];
}
if ( ! $this -> isBooleanConfigOptionSet ( 'asteriskAccount_hideAstAccountLastQualifyMilliseconds' )) {
$this -> attributes [ 'AstAccountLastQualifyMilliseconds' ][ 0 ] = $_POST [ 'AstAccountLastQualifyMilliseconds' ];
}
2009-11-21 15:25:05 +00:00
return $errors ;
}
2009-11-24 12:09:29 +00:00
/**
* Returns a list of modifications which have to be made to the LDAP account .
*
* @ return array list of modifications
* < br > This function returns an array with 3 entries :
* < br > array ( DN1 ( 'add' => array ( $attr ), 'remove' => array ( $attr ), 'modify' => array ( $attr )), DN2 .... )
* < br > DN is the DN to change . It may be possible to change several DNs ( e . g . create a new user and add him to some groups via attribute memberUid )
* < br > " add " are attributes which have to be added to LDAP entry
* < br > " remove " are attributes which have to be removed from LDAP entry
* < br > " modify " are attributes which have to been modified in LDAP entry
2011-02-26 13:14:10 +00:00
* < br > " info " are values with informational value ( e . g . to be used later by pre / postModify actions )
2009-11-24 12:09:29 +00:00
*/
function save_attributes () {
if ( ! in_array ( 'AsteriskSIPUser' , $this -> attributes [ 'objectClass' ])) {
return array ();
}
return $this -> getAccountContainer () -> save_module_attributes ( $this -> attributes , $this -> orig );
}
2009-11-22 13:41:20 +00:00
/**
2017-02-19 08:14:11 +00:00
* { @ inheritDoc }
* @ see baseModule :: get_pdfEntries ()
2015-01-07 17:16:35 +00:00
*/
2017-04-01 07:57:03 +00:00
function get_pdfEntries ( $pdfKeys , $typeId ) {
2009-11-22 13:41:20 +00:00
$return = array ();
2013-05-05 13:50:19 +00:00
$this -> addSimplePDFField ( $return , 'AstAccountCallerID' , _ ( 'Caller ID' ));
$this -> addSimplePDFField ( $return , 'AstAccountContext' , _ ( 'Account context' ));
$this -> addSimplePDFField ( $return , 'AstAccountHost' , _ ( 'Host' ));
$this -> addSimplePDFField ( $return , 'AstAccountType' , _ ( 'Account type' ));
$this -> addSimplePDFField ( $return , 'AstAccountUserAgent' , _ ( 'User agent' ));
$this -> addSimplePDFField ( $return , 'AstAccountAMAFlags' , _ ( 'AMA flags' ));
$this -> addSimplePDFField ( $return , 'AstAccountCallGroup' , _ ( 'Call groups' ));
$this -> addSimplePDFField ( $return , 'AstAccountDTMFMode' , _ ( 'DTMF mode' ));
$this -> addSimplePDFField ( $return , 'AstAccountFromUser' , _ ( 'From user' ));
$this -> addSimplePDFField ( $return , 'AstAccountFromDomain' , _ ( 'From domain' ));
$this -> addSimplePDFField ( $return , 'AstAccountFullContact' , _ ( 'Full contact' ));
$this -> addSimplePDFField ( $return , 'AstAccountInsecure' , _ ( 'Insecure' ));
$this -> addSimplePDFField ( $return , 'AstAccountMailbox' , _ ( 'Mailbox' ));
$this -> addSimplePDFField ( $return , 'AstAccountNAT' , _ ( 'NAT' ));
$this -> addSimplePDFField ( $return , 'AstAccountDeny' , _ ( 'Deny' ));
$this -> addSimplePDFField ( $return , 'AstAccountPermit' , _ ( 'Permit' ));
$this -> addSimplePDFField ( $return , 'AstAccountPickupGroup' , _ ( 'Pickup group' ));
$this -> addSimplePDFField ( $return , 'AstAccountPort' , _ ( 'Port' ));
$this -> addSimplePDFField ( $return , 'AstAccountQualify' , _ ( 'Qualify' ));
$this -> addSimplePDFField ( $return , 'AstAccountRestrictCID' , _ ( 'Restrict caller ID' ));
$this -> addSimplePDFField ( $return , 'AstAccountRTPTimeout' , _ ( 'RTP timeout' ));
$this -> addSimplePDFField ( $return , 'AstAccountRTPHoldTimeout' , _ ( 'RTP hold timeout' ));
$this -> addSimplePDFField ( $return , 'AstAccountDisallowedCodec' , _ ( 'Disallowed codec' ));
$this -> addSimplePDFField ( $return , 'AstAccountAllowedCodec' , _ ( 'Allowed codec' ));
$this -> addSimplePDFField ( $return , 'AstAccountMusicOnHold' , _ ( 'Music on hold' ));
$this -> addSimplePDFField ( $return , 'AstAccountExpirationTimestamp' , _ ( 'Expiration timestamp' ));
$this -> addSimplePDFField ( $return , 'AstAccountRegistrationContext' , _ ( 'Registration context' ));
$this -> addSimplePDFField ( $return , 'AstAccountRegistrationExten' , _ ( 'Registration extension' ));
$this -> addSimplePDFField ( $return , 'AstAccountCanCallForward' , _ ( 'Can call forward' ));
$this -> addSimplePDFField ( $return , 'AstAccountIPAddress' , _ ( 'IP address' ));
$this -> addSimplePDFField ( $return , 'AstAccountDefaultUser' , _ ( 'Default user' ));
$this -> addSimplePDFField ( $return , 'AstAccountRegistrationServer' , _ ( 'Registration server' ));
$this -> addSimplePDFField ( $return , 'AstAccountLastQualifyMilliseconds' , _ ( 'Last qualify milliseconds' ));
2009-11-22 13:41:20 +00:00
return $return ;
}
2009-11-21 15:25:05 +00:00
/**
2017-05-20 09:46:49 +00:00
* { @ inheritDoc }
* @ see baseModule :: build_uploadAccounts ()
2009-11-21 15:25:05 +00:00
*/
2017-05-20 09:46:49 +00:00
function build_uploadAccounts ( $rawAccounts , $ids , & $partialAccounts , $selectedModules , & $type ) {
2009-11-21 15:25:05 +00:00
$messages = array ();
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
// add object class
if ( ! in_array ( " AsteriskSIPUser " , $partialAccounts [ $i ][ 'objectClass' ])) $partialAccounts [ $i ][ 'objectClass' ][] = " AsteriskSIPUser " ;
2009-11-22 13:41:20 +00:00
// add account caller id
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountCallerID' , 'AstAccountCallerID' ,
'username' , $this -> messages [ 'AstAccountCallerID' ][ 3 ], $messages );
2009-11-22 13:41:20 +00:00
// add host
2014-04-12 17:52:33 +00:00
if ( empty ( $rawAccounts [ $i ][ $ids [ 'asteriskAccount_AstAccountHost' ]])) {
2009-11-22 13:41:20 +00:00
// default value
$partialAccounts [ $i ][ 'AstAccountHost' ] = 'dynamic' ;
}
2009-11-21 15:25:05 +00:00
else {
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountHost' , 'AstAccountHost' ,
'realname' , $this -> messages [ 'AstAccountHost' ][ 2 ], $messages );
2009-11-21 15:25:05 +00:00
}
2009-11-22 13:41:20 +00:00
//add context
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountContext' , 'AstAccountContext' ,
'realname' , $this -> messages [ 'AstAccountContext' ][ 2 ], $messages );
2011-02-24 18:51:57 +00:00
//add account type
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountType' , 'AstAccountType' ,
'username' , $this -> messages [ 'AstAccountType' ][ 2 ], $messages );
2009-11-22 13:41:20 +00:00
//add password
if ( $rawAccounts [ $i ][ $ids [ 'asteriskAccount_AstAccountRealmedPassword' ]] != " " ) {
2010-04-07 19:24:27 +00:00
$attributes = array ( 'AstAccountCallerID' => array ( $partialAccounts [ $i ][ 'AstAccountCallerID' ])); // fake attribute list for password building
$pwdString = asteriskAccount :: buildPasswordString ( $attributes , $this -> moduleSettings , $rawAccounts [ $i ][ $ids [ 'asteriskAccount_AstAccountRealmedPassword' ]]);
$partialAccounts [ $i ][ 'AstAccountRealmedPassword' ] = $pwdString ;
2009-11-21 15:25:05 +00:00
}
2017-02-19 08:14:11 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountUserAgent' , 'AstAccountUserAgent' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountAMAFlags' , 'AstAccountAMAFlags' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountCallGroup' , 'AstAccountCallGroup' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountDTMFMode' , 'AstAccountDTMFMode' );
2011-03-31 18:48:15 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountFromUser' , 'AstAccountFromUser' ,
'username' , $this -> messages [ 'AstAccountFromUser' ][ 1 ], $messages );
2011-03-31 18:48:15 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountFromDomain' , 'AstAccountFromDomain' ,
'domainname' , $this -> messages [ 'AstAccountFromDomain' ][ 1 ], $messages );
2011-03-31 18:48:15 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountFullContact' , 'AstAccountFullContact' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountInsecure' , 'AstAccountInsecure' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountMailbox' , 'AstAccountMailbox' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountNAT' , 'AstAccountNAT' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountDeny' , 'AstAccountDeny' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountPermit' , 'AstAccountPermit' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountPickupGroup' , 'AstAccountPickupGroup' );
2017-02-19 08:14:11 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountPort' , 'AstAccountPort' ,
'digit' , $this -> messages [ 'AstAccountPort' ][ 1 ], $messages );
2017-02-19 08:14:11 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountQualify' , 'AstAccountQualify' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountRestrictCID' , 'AstAccountRestrictCID' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountRTPTimeout' , 'AstAccountRTPTimeout' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountRTPHoldTimeout' , 'AstAccountRTPHoldTimeout' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountDisallowedCodec' , 'AstAccountDisallowedCodec' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountAllowedCodec' , 'AstAccountAllowedCodec' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountMusicOnHold' , 'AstAccountMusicOnHold' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountExpirationTimestamp' , 'AstAccountExpirationTimestamp' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountRegistrationContext' , 'AstAccountRegistrationContext' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountRegistrationExten' , 'AstAccountRegistrationExten' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountCanCallForward' , 'AstAccountCanCallForward' );
2017-02-19 08:14:11 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountIPAddress' , 'AstAccountIPAddress' ,
'ip' , $this -> messages [ 'AstAccountIPAddress' ][ 1 ], $messages );
2017-02-19 08:14:11 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountDefaultUser' , 'AstAccountDefaultUser' ,
'username' , $this -> messages [ 'AstAccountDefaultUser' ][ 1 ], $messages );
2017-02-19 08:14:11 +00:00
2014-04-12 17:52:33 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountRegistrationServer' , 'AstAccountRegistrationServer' );
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'asteriskAccount_AstAccountLastQualifyMilliseconds' , 'AstAccountLastQualifyMilliseconds' );
2009-11-21 15:25:05 +00:00
}
return $messages ;
}
2010-03-17 17:48:42 +00:00
/**
2009-11-21 15:25:05 +00:00
* This method specifies if a module manages password attributes .
* @ see passwordService :: managesPasswordAttributes
*
* @ return boolean true if this module manages password attributes
*/
public function managesPasswordAttributes () {
2010-04-01 17:31:55 +00:00
if ( ! in_array ( 'AsteriskSIPUser' , $this -> attributes [ 'objectClass' ])) {
return false ;
}
2009-11-21 15:25:05 +00:00
return true ;
}
2012-01-15 19:34:14 +00:00
/**
* Specifies if this module supports to force that a user must change his password on next login .
2017-02-19 08:14:11 +00:00
*
2012-01-15 19:34:14 +00:00
* @ return boolean force password change supported
*/
public function supportsForcePasswordChange () {
return false ;
}
2017-02-19 08:14:11 +00:00
2009-11-21 15:25:05 +00:00
/**
* This function is called whenever the password should be changed . Account modules
* must change their password attributes only if the modules list contains their module name .
*
* @ param String $password new password
* @ param $modules list of modules for which the password should be changed
2012-01-15 19:34:14 +00:00
* @ param boolean $forcePasswordChange force the user to change his password at next login
2009-11-21 15:25:05 +00:00
* @ return array list of error messages if any as parameter array for StatusMessage
* e . g . return arrray ( array ( 'ERROR' , 'Password change failed.' ))
* @ see passwordService :: passwordChangeRequested
*/
2012-01-15 19:34:14 +00:00
public function passwordChangeRequested ( $password , $modules , $forcePasswordChange ) {
2009-11-21 15:25:05 +00:00
if ( ! in_array ( get_class ( $this ), $modules )) {
return array ();
}
2010-04-07 19:24:27 +00:00
$this -> attributes [ 'AstAccountRealmedPassword' ][ 0 ] = asteriskAccount :: buildPasswordString ( $this -> attributes , $this -> moduleSettings , $password );
2009-11-21 15:25:05 +00:00
return array ();
}
2017-02-19 08:14:11 +00:00
2010-06-12 17:17:31 +00:00
/**
* Builds the password string for the password attribute .
*
* @ param array $attributes LDAP attributes
* @ param array $moduleSettings module configuration settings
* @ param String $password password
* @ return String value for password attribute
*/
2010-04-07 19:24:27 +00:00
public static function buildPasswordString ( & $attributes , & $moduleSettings , $password ) {
$astRealm = asteriskAccount :: ASTERISK_DEFAULT_REALM ;
$asteriskRealmFromProfile = $moduleSettings [ 'asteriskAccount_AsteriskRealm' ][ 0 ];
if ( $asteriskRealmFromProfile != " " ){
$astRealm = $asteriskRealmFromProfile ;
}
return asteriskAccount :: hashPassword ( $attributes [ 'AstAccountCallerID' ][ 0 ] . " : " . $astRealm . " : " . $password );
}
2017-02-19 08:14:11 +00:00
2009-11-22 13:41:20 +00:00
/**
* Hashes a password value to Asterisk format .
*
* @ param String $password password
* @ return String hash
*/
2010-04-07 19:24:27 +00:00
private static function hashPassword ( $password ) {
2010-03-17 17:48:42 +00:00
return " { MD5} " . md5 ( $password );
2009-11-22 13:41:20 +00:00
}
2009-11-21 15:25:05 +00:00
2010-09-02 18:21:59 +00:00
/**
2011-02-26 13:14:10 +00:00
* Checks if all input values are correct and returns the LDAP attributes which should be changed .
* < br > Return values :
* < br > messages : array of parameters to create status messages
* < br > add : array of attributes to add
* < br > del : array of attributes to remove
* < br > mod : array of attributes to modify
* < br > info : array of values with informational value ( e . g . to be used later by pre / postModify actions )
2017-02-19 08:14:11 +00:00
*
2011-02-26 13:14:10 +00:00
* Calling this method does not require the existence of an enclosing { @ link accountContainer } .
2010-09-02 18:21:59 +00:00
*
* @ param string $fields input fields
* @ param array $attributes LDAP attributes
2012-02-08 17:55:00 +00:00
* @ param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
2012-08-18 15:55:43 +00:00
* @ param array $readOnlyFields list of read - only fields
2011-02-26 13:14:10 +00:00
* @ return array messages and attributes ( array ( 'messages' => array (), 'add' => array ( 'mail' => array ( 'test@test.com' )), 'del' => array (), 'mod' => array (), 'info' => array ()))
2010-09-02 18:21:59 +00:00
*/
2012-08-18 15:55:43 +00:00
function checkSelfServiceOptions ( $fields , $attributes , $passwordChangeOnly , $readOnlyFields ) {
2011-02-26 13:14:10 +00:00
$return = array ( 'messages' => array (), 'add' => array (), 'del' => array (), 'mod' => array (), 'info' => array ());
2012-02-08 17:55:00 +00:00
if ( ! isset ( $attributes [ 'objectClass' ]) || ! in_array_ignore_case ( 'AsteriskSIPUser' , $attributes [ 'objectClass' ])) {
2010-09-02 18:21:59 +00:00
return $return ;
}
if ( isset ( $_POST [ 'posixAccount_password' ]) && ( $_POST [ 'posixAccount_password' ] != '' )) {
if ( $_POST [ 'posixAccount_password' ] != $_POST [ 'posixAccount_password2' ]) {
return $return ;
}
else {
if ( ! get_preg ( $_POST [ 'posixAccount_password' ], 'password' )) {
return $return ;
}
else {
// sync password
if ( in_array ( 'syncAsteriskPassword' , $fields )) {
$return [ 'mod' ][ 'AstAccountRealmedPassword' ][ 0 ] = asteriskAccount :: buildPasswordString ( $attributes , $this -> selfServiceSettings -> moduleSettings , $_POST [ 'posixAccount_password' ]);
}
}
}
}
return $return ;
}
2014-01-25 14:14:46 +00:00
/**
* Returns a list of configuration options .
2017-02-19 08:14:11 +00:00
*
2014-01-25 14:14:46 +00:00
* Calling this method does not require the existence of an enclosing { @ link accountContainer } .< br >
* < br >
* The field names are used as keywords to load and save settings .
* We recommend to use the module name as prefix for them ( e . g . posixAccount_homeDirectory ) to avoid naming conflicts .
*
* @ param array $scopes account types ( user , group , host )
* @ param array $allScopes list of all active account modules and their scopes ( module => array ( scopes ))
* @ return mixed htmlElement or array of htmlElement
2017-02-19 08:14:11 +00:00
*
2014-01-25 14:14:46 +00:00
* @ see htmlElement
*/
public function get_configOptions ( $scopes , $allScopes ) {
2017-11-25 16:51:13 +00:00
$configContainer = new htmlResponsiveRow ();
$configContainer -> add ( new htmlResponsiveInputField ( _ ( 'Asterisk realm' ), 'asteriskAccount_AsteriskRealm' , null , 'AsteriskRealm' ), 12 );
$configContainer -> addVerticalSpacer ( '1rem' );
$configHiddenHead = new htmlGroup ();
2014-01-25 14:14:46 +00:00
$configHiddenHead -> addElement ( new htmlOutputText ( _ ( 'Hidden options' )));
$configHiddenHead -> addElement ( new htmlHelpLink ( 'hiddenOptions' ));
2017-11-25 16:51:13 +00:00
$configContainer -> add ( $configHiddenHead , 12 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountUserAgent' , false , _ ( 'User agent' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountAMAFlags' , false , _ ( 'AMA flags' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountCallGroup' , false , _ ( 'Call groups' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountDTMFMode' , false , _ ( 'DTFM flags' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountFromUser' , false , _ ( 'From user' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountFromDomain' , false , _ ( 'From domain' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountFullContact' , false , _ ( 'Full contact' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountInsecure' , false , _ ( 'Insecure' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountMailbox' , false , _ ( 'Mailbox' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountNAT' , false , _ ( 'NAT' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountDeny' , false , _ ( 'Deny' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountPermit' , false , _ ( 'Permit' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountPickupGroup' , false , _ ( 'Pickup group' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountPort' , false , _ ( 'Port' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountQualify' , false , _ ( 'Qualify' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountRestrictCID' , false , _ ( 'Restrict caller ID' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountRTPTimeout' , false , _ ( 'RTP timeout' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountRTPHoldTimeout' , false , _ ( 'RTP hold timeout' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountDisallowedCodec' , false , _ ( 'Disallowed codec' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountAllowedCodec' , false , _ ( 'Allowed codec' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountMusicOnHold' , false , _ ( 'Music on hold' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountExpirationTimestamp' , false , _ ( 'Expiration timestamp' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountRegistrationContext' , false , _ ( 'Registration context' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountRegistrationExten' , false , _ ( 'Registration extension' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountCanCallForward' , false , _ ( 'Can call forward' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountIPAddress' , false , _ ( 'IP address' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountDefaultUser' , false , _ ( 'Default user' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountRegistrationServer' , false , _ ( 'Registration server' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'asteriskAccount_hideAstAccountLastQualifyMilliseconds' , false , _ ( 'Last qualify milliseconds' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlOutputText ( '' ), 0 , 4 );
return $configContainer ;
2014-01-25 14:14:46 +00:00
}
2017-02-19 08:14:11 +00:00
2009-11-21 15:25:05 +00:00
}
?>