~ubuntu-branches/ubuntu/trusty/ldap-account-manager/trusty

« back to all changes in this revision

Viewing changes to lib/modules/asteriskAccount.inc

  • Committer: Package Import Robot
  • Author(s): Roland Gruber
  • Date: 2012-03-25 11:00:20 UTC
  • mfrom: (1.1.22) (4.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20120325110020-bggr97wusvitsvqg
Tags: 3.7-1
* new upstream release
* Fix "[INTL:nl] Dutch translation of debconf templates" (Closes: #658463)
* Fix "[INTL:da] Danish translation of the debconf templates ldap-
  account-manager" (Closes: #661950)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/*
3
 
$Id: asteriskAccount.inc,v 1.29 2011/10/19 17:57:57 gruberroland Exp $
 
3
$Id: asteriskAccount.inc,v 1.35 2012/02/16 07:30:15 gruberroland Exp $
4
4
 
5
5
  This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
6
 
  Copyright (C) 2009 - 2011  Pavel Pozdnyak
7
 
                2009 - 2011  Roland Gruber
 
6
  Copyright (C) 2009 - 2012  Pavel Pozdnyak
 
7
                2009 - 2012  Roland Gruber
8
8
 
9
9
  This program is free software; you can redistribute it and/or modify
10
10
  it under the terms of the GNU General Public License as published by
60
60
        function get_metaData() {
61
61
                $return = array();      
62
62
                // manages users accounts
63
 
                $return["account_types"] = array("user");
 
63
                $return["account_types"] = array("user", "host");
64
64
                $return["is_base"] = false;
65
65
                // alias name
66
66
                $return["alias"] = _("Asterisk");
67
67
                // module dependencies
68
 
                $return['dependencies'] = array('depends' => array('inetOrgPerson'), 'conflicts' => array());
 
68
                $return['dependencies'] = array('depends' => array(), 'conflicts' => array());
69
69
                // managed object classes
70
70
                $return['objectClasses'] = array('AsteriskSIPUser');
71
71
                // managed attributes
91
91
                // help
92
92
                $return['help'] = array(
93
93
                        'AstAccountCallerID' => array(
94
 
                                "Headline" => _("Caller ID"),
 
94
                                "Headline" => _("Caller ID"), 'attr' => 'AstAccountCallerID',
95
95
                                "Text" => _("This is the ID of the user in the Asterisk database. It may contain digits and letters (e.g. user1 or 200134).")
96
96
                        ),
97
97
                        'AstAccountHost' => array(
98
 
                                "Headline" => _("Host"),
 
98
                                "Headline" => _("Host"), 'attr' => 'AstAccountHost',
99
99
                                "Text" => _("This is the machine id (e.g. IP address or host name) from which the user can call/receive calls.")
100
100
                        ),
101
101
                        'AstAccountContext' => array(
102
 
                                "Headline" => _("Account context"),
 
102
                                "Headline" => _("Account context"), 'attr' => 'AstAccountContext',
103
103
                                "Text" => _("The account context stores information about the dial plan.")
104
104
                        ),
105
105
                        'AstAccountRealmedPassword' => array(
106
 
                                "Headline" => _("Password"),
 
106
                                "Headline" => _("Password"), 'attr' => 'AstAccountRealmedPassword',
107
107
                                "Text" => _("Please enter the password which you want to set for this account.")
108
108
                        ),
109
109
                        'AstAccountType' => array(
110
 
                                "Headline" => _("Account type"),
 
110
                                "Headline" => _("Account type"), 'attr' => 'AstAccountType',
111
111
                                "Text" => _("Please enter the account's type (e.g. \"friend\").")
112
112
                        ),
113
113
                        'AsteriskRealm' => array(
115
115
                                "Text" => _("Authentication realm for Asterisk server (default: asterisk). This value set in sip.conf (option: \"realm\").")
116
116
                        ),
117
117
                        'AstAccountUserAgent' => array(
118
 
                                "Headline" => _("User agent"),
 
118
                                "Headline" => _("User agent"), 'attr' => 'AstAccountUserAgent',
119
119
                                "Text" => _("SIP user agent identification.")
120
120
                        ),
121
121
                        'AstAccountAMAFlags' => array(
122
 
                                "Headline" => _("AMA flags"),
 
122
                                "Headline" => _("AMA flags"), 'attr' => 'AstAccountAMAFlags',
123
123
                                "Text" => _("Asterisk AMA (Automated Message Accounting) flags.")
124
124
                        ),
125
125
                        'AstAccountCallGroup' => array(
126
 
                                "Headline" => _("Call groups"),
 
126
                                "Headline" => _("Call groups"), 'attr' => 'AstAccountCallGroup',
127
127
                                "Text" => _("The user's call groups.")
128
128
                        ),                    
129
129
                        'AstAccountDTMFMode' => array(
130
 
                                "Headline" => _("DTMF mode"),
 
130
                                "Headline" => _("DTMF mode"), 'attr' => 'AstAccountDTMFMode',
131
131
                                "Text" => _("DTMF mode for SIP client configuration.")
132
132
                        ),
133
133
                        'AstAccountFromUser' => array(
134
 
                                "Headline" => _("From user"),
 
134
                                "Headline" => _("From user"), 'attr' => 'AstAccountFromUser',
135
135
                                "Text" => _("From user setting for this account.")
136
136
                        ),
137
137
                        'AstAccountFromDomain' => array(
138
 
                                "Headline" => _("From domain"),
 
138
                                "Headline" => _("From domain"), 'attr' => 'AstAccountFromDomain',
139
139
                                "Text" => _("From domain setting for this account.")
140
140
                        ),
141
141
                        'AstAccountFullContact' => array(
142
 
                                "Headline" => _("Full contact"),
 
142
                                "Headline" => _("Full contact"), 'attr' => 'AstAccountFullContact',
143
143
                                "Text" => _("SIP URI for a realtime peer.")
144
144
                        ),
145
145
                        'AstAccountInsecure' => array(
146
 
                                "Headline" => _("Insecure"),
 
146
                                "Headline" => _("Insecure"), 'attr' => 'AstAccountInsecure',
147
147
                                "Text" => _("This is typically used to allow incoming calls (e.g. from FWD) while having a type=friend entry defined with username and password.")
148
148
                        ),
149
149
                        'AstAccountMailbox' => array(
150
 
                                "Headline" => _("Mailbox"),
 
150
                                "Headline" => _("Mailbox"), 'attr' => 'AstAccountMailbox',
151
151
                                "Text" => _("Defines the mailbox to check for message waiting indication (MWI) for this peer.")
152
152
                        ),
153
153
                        'AstAccountNAT' => array(
154
 
                                "Headline" => _("NAT"),
 
154
                                "Headline" => _("NAT"), 'attr' => 'AstAccountNAT',
155
155
                                "Text" => _("NAT setting for this account.")
156
156
                        ),
157
157
                        'AstAccountDeny' => array(
158
 
                                "Headline" => _("Deny"),
 
158
                                "Headline" => _("Deny"), 'attr' => 'AstAccountDeny',
159
159
                                "Text" => _("Used to limit SIP traffic to and from this peer to a certain IP or network.")
160
160
                        ),
161
161
                        'AstAccountPermit' => array(
162
 
                                "Headline" => _("Permit"),
 
162
                                "Headline" => _("Permit"), 'attr' => 'AstAccountPermit',
163
163
                                "Text" => _("Used to limit SIP traffic to and from this peer to a certain IP or network.")
164
164
                        ),
165
165
                        'AstAccountPickupGroup' => array(
166
 
                                "Headline" => _("Pickup group"),
 
166
                                "Headline" => _("Pickup group"), 'attr' => 'AstAccountPickupGroup',
167
167
                                "Text" => _("Specifies the user's pickup group.")
168
168
                        ),
169
169
                        'AstAccountPort' => array(
170
 
                                "Headline" => _("Port"),
 
170
                                "Headline" => _("Port"), 'attr' => 'AstAccountPort',
171
171
                                "Text" => _("Port number.")
172
172
                        ),
173
173
                        'AstAccountQualify' => array(
174
 
                                "Headline" => _("Qualify"),
 
174
                                "Headline" => _("Qualify"), 'attr' => 'AstAccountQualify',
175
175
                                "Text" => _("Used to regularly check that a device is still online.")
176
176
                        ),
177
177
                        'AstAccountRestrictCID' => array(
178
 
                                "Headline" => _("Restrict caller ID"),
 
178
                                "Headline" => _("Restrict caller ID"), 'attr' => 'AstAccountRestrictCID',
179
179
                                "Text" => _("Use this to hide the caller ID.")
180
180
                        ),
181
181
                        'AstAccountRTPTimeout' => array(
182
 
                                "Headline" => _("RTP timeout"),
 
182
                                "Headline" => _("RTP timeout"), 'attr' => 'AstAccountRTPTimeout',
183
183
                                "Text" => _("Used to automatically hangup the call if no RTP traffic is received.")
184
184
                        ),
185
185
                        'AstAccountRTPHoldTimeout' => array(
186
 
                                "Headline" => _("RTP hold timeout"),
 
186
                                "Headline" => _("RTP hold timeout"), 'attr' => 'AstAccountRTPHoldTimeout',
187
187
                                "Text" => _("Maximum number of seconds of inactivity before terminating a call on hold.")
188
188
                        ),
189
189
                        'AstAccountDisallowedCodec' => array(
190
 
                                "Headline" => _("Disallowed codec"),
 
190
                                "Headline" => _("Disallowed codec"), 'attr' => 'AstAccountDisallowedCodec',
191
191
                                "Text" => _("List of disallowed codecs.")
192
192
                        ),
193
193
                        'AstAccountAllowedCodec' => array(
194
 
                                "Headline" => _("Allowed codec"),
 
194
                                "Headline" => _("Allowed codec"), 'attr' => 'AstAccountAllowedCodec',
195
195
                                "Text" => _("List of allowed codecs.")
196
196
                        ),
197
197
                        'AstAccountMusicOnHold' => array(
198
 
                                "Headline" => _("Music on hold"),
 
198
                                "Headline" => _("Music on hold"), 'attr' => 'AstAccountMusicOnHold',
199
199
                                "Text" => _("Music to play on hold.")
200
200
                        ),
201
201
                        'AstAccountExpirationTimestamp' => array(
202
 
                                "Headline" => _("Expiration timestamp"),
 
202
                                "Headline" => _("Expiration timestamp"), 'attr' => 'AstAccountExpirationTimestamp',
203
203
                                "Text" => _("Expiration timestamp (\"regseconds\" option).")
204
204
                        ),
205
205
                        'AstAccountRegistrationContext' => array(
206
 
                                "Headline" => _("Registration context"),
 
206
                                "Headline" => _("Registration context"), 'attr' => 'AstAccountRegistrationContext',
207
207
                                "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.")
208
208
                        ),
209
209
                        'AstAccountRegistrationExten' => array(
210
 
                                "Headline" => _("Registration extension"),
 
210
                                "Headline" => _("Registration extension"), 'attr' => 'AstAccountRegistrationExten',
211
211
                                "Text" => _("Used for registration context.")
212
212
                        ),
213
213
                        'AstAccountCanCallForward' => array(
214
 
                                "Headline" => _("Can call forward"),
 
214
                                "Headline" => _("Can call forward"), 'attr' => 'AstAccountCanCallForward',
215
215
                                "Text" => _("Specifies if the user can call forward.")
216
216
                        ),
217
217
                        'AstAccountIPAddress' => array(
218
 
                                "Headline" => _("IP address"),
 
218
                                "Headline" => _("IP address"), 'attr' => 'AstAccountIPAddress',
219
219
                                "Text" => _("IP address of the peer. Valid only for realtime peers.")
220
220
                        ),
221
221
                        'AstAccountDefaultUser' => array(
222
 
                                "Headline" => _("Default user"),
 
222
                                "Headline" => _("Default user"), 'attr' => 'AstAccountDefaultUser',
223
223
                                "Text" => _("Authentication user for outbound proxies.")
224
224
                        ),
225
225
                        'AstAccountRegistrationServer' => array(
226
 
                                "Headline" => _("Registration server"),
 
226
                                "Headline" => _("Registration server"), 'attr' => 'AstAccountRegistrationServer',
227
227
                                "Text" => _("IP address or domain name of the registration server.")
228
228
                        ),
229
229
                        'AstAccountLastQualifyMilliseconds' => array(
230
 
                                "Headline" => _("Last qualify milliseconds"),
 
230
                                "Headline" => _("Last qualify milliseconds"), 'attr' => 'AstAccountLastQualifyMilliseconds',
231
231
                                "Text" => _("The number of milliseconds for the last qualify.")
232
232
                        ),
233
233
                        'hiddenOptions' => array(
253
253
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountCallGroup', false, _('Call groups'), null, false));
254
254
                $configContainerOptions->addElement(new htmlOutputText(' '));
255
255
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountDTMFMode', false, _('DTFM flags'), null, false));
256
 
                $configContainerOptions->addNewLine();
 
256
                $configContainerOptions->addElement(new htmlOutputText(' '));
257
257
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountFromUser', false, _('From user'), null, false));
258
 
                $configContainerOptions->addElement(new htmlOutputText(' '));
 
258
                $configContainerOptions->addNewLine();
259
259
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountFromDomain', false, _('From domain'), null, false));
260
260
                $configContainerOptions->addElement(new htmlOutputText(' '));
261
261
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountFullContact', false, _('Full contact'), null, false));
262
262
                $configContainerOptions->addElement(new htmlOutputText(' '));
263
263
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountInsecure', false, _('Insecure'), null, false));
264
 
                $configContainerOptions->addNewLine();
 
264
                $configContainerOptions->addElement(new htmlOutputText(' '));
265
265
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountMailbox', false, _('Mailbox'), null, false));
266
266
                $configContainerOptions->addElement(new htmlOutputText(' '));
267
267
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountNAT', false, _('NAT'), null, false));
268
 
                $configContainerOptions->addElement(new htmlOutputText(' '));
 
268
                $configContainerOptions->addNewLine();
269
269
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountDeny', false, _('Deny'), null, false));
270
270
                $configContainerOptions->addElement(new htmlOutputText(' '));
271
271
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountPermit', false, _('Permit'), null, false));
272
 
                $configContainerOptions->addNewLine();
 
272
                $configContainerOptions->addElement(new htmlOutputText(' '));
273
273
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountPickupGroup', false, _('Pickup group'), null, false));
274
274
                $configContainerOptions->addElement(new htmlOutputText(' '));
275
275
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountPort', false, _('Port'), null, false));
276
276
                $configContainerOptions->addElement(new htmlOutputText(' '));
277
277
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountQualify', false, _('Qualify'), null, false));
278
 
                $configContainerOptions->addElement(new htmlOutputText(' '));
 
278
                $configContainerOptions->addNewLine();
279
279
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountRestrictCID', false, _('Restrict caller ID'), null, false));
280
 
                $configContainerOptions->addNewLine();
 
280
                $configContainerOptions->addElement(new htmlOutputText(' '));
281
281
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountRTPTimeout', false, _('RTP timeout'), null, false));
282
282
                $configContainerOptions->addElement(new htmlOutputText(' '));
283
283
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountRTPHoldTimeout', false, _('RTP hold timeout'), null, false));
293
293
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountRegistrationContext', false, _('Registration context'), null, false));
294
294
                $configContainerOptions->addElement(new htmlOutputText(' '));
295
295
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountRegistrationExten', false, _('Registration extension'), null, false));
296
 
                $configContainerOptions->addNewLine();
 
296
                $configContainerOptions->addElement(new htmlOutputText(' '));
297
297
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountCanCallForward', false, _('Can call forward'), null, false));
298
 
                $configContainerOptions->addElement(new htmlOutputText(' '));
 
298
                $configContainerOptions->addNewLine();
299
299
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountIPAddress', false, _('IP address'), null, false));
300
300
                $configContainerOptions->addElement(new htmlOutputText(' '));
301
301
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountDefaultUser', false, _('Default user'), null, false));
302
302
                $configContainerOptions->addElement(new htmlOutputText(' '));
303
303
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountRegistrationServer', false, _('Registration server'), null, false));
304
 
                $configContainerOptions->addNewLine();
 
304
                $configContainerOptions->addElement(new htmlOutputText(' '));
305
305
                $configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('asteriskAccount_hideAstAccountLastQualifyMilliseconds', false, _('Last qualify milliseconds'), null, false));
306
306
                $configContainerOptions->addNewLine();
307
307
                $configContainer->addElement($configContainerOptions, true);
359
359
                        'AstAccountRegistrationServer' => _('Registration server'),
360
360
                        'AstAccountLastQualifyMilliseconds' => _('Last qualify milliseconds'),
361
361
                );
362
 
                // upload dependencies
363
 
                $return['upload_preDepends'] = array('posixAccount', 'inetOrgPerson');
364
362
                // upload fields
365
363
                $return['upload_columns'] = array(
366
364
                        array(
647
645
         * @return htmlElement HTML meta data
648
646
         */
649
647
        function display_html_attributes() {
650
 
                if (isset($_POST['addObjectClass'])) {
651
 
                        $this->attributes['objectClass'][] = 'AsteriskSIPUser';
652
 
                }
653
 
 
654
648
                $return = new htmlTable();
655
649
                if (in_array('AsteriskSIPUser', $this->attributes['objectClass'])) {
656
650
                        // caller ID
980
974
         * Write variables into object and do some regex checks
981
975
         */
982
976
        function process_attributes() {
 
977
                if (isset($_POST['addObjectClass'])) {
 
978
                        $this->attributes['objectClass'][] = 'AsteriskSIPUser';
 
979
                        return array();
 
980
                }
983
981
                if (!in_array('AsteriskSIPUser', $this->attributes['objectClass'])) {
984
982
                        return array();
985
983
                }
1512
1510
        }
1513
1511
 
1514
1512
        /**
 
1513
         * Specifies if this module supports to force that a user must change his password on next login.
 
1514
         * 
 
1515
         * @return boolean force password change supported
 
1516
         */
 
1517
        public function supportsForcePasswordChange() {
 
1518
                return false;
 
1519
        }
 
1520
        
 
1521
        /**
1515
1522
         * This function is called whenever the password should be changed. Account modules
1516
1523
         * must change their password attributes only if the modules list contains their module name.
1517
1524
         *
1518
1525
         * @param String $password new password
1519
1526
         * @param $modules list of modules for which the password should be changed
 
1527
         * @param boolean $forcePasswordChange force the user to change his password at next login
1520
1528
         * @return array list of error messages if any as parameter array for StatusMessage
1521
1529
         *                         e.g. return arrray(array('ERROR', 'Password change failed.'))
1522
1530
         * @see passwordService::passwordChangeRequested
1523
1531
         */
1524
 
        public function passwordChangeRequested($password, $modules) {
 
1532
        public function passwordChangeRequested($password, $modules, $forcePasswordChange) {
1525
1533
                if (!in_array(get_class($this), $modules)) {
1526
1534
                        return array();
1527
1535
                }
1569
1577
         *
1570
1578
         * @param string $fields input fields
1571
1579
         * @param array $attributes LDAP attributes
 
1580
         * @param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
1572
1581
         * @return array messages and attributes (array('messages' => array(), 'add' => array('mail' => array('test@test.com')), 'del' => array(), 'mod' => array(), 'info' => array()))
1573
1582
         */
1574
 
        function checkSelfServiceOptions($fields, $attributes) {
 
1583
        function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly) {
1575
1584
                $return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array(), 'info' => array());
1576
 
                if (!in_array_ignore_case('AsteriskSIPUser', $attributes['objectClass'])) {
 
1585
                if (!isset($attributes['objectClass']) || !in_array_ignore_case('AsteriskSIPUser', $attributes['objectClass'])) {
1577
1586
                        return $return;
1578
1587
                }
1579
1588
                if (isset($_POST['posixAccount_password']) && ($_POST['posixAccount_password'] != '')) {