2005-08-01 11:58:07 +00:00
< ? php
/*
$Id $
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager ( http :// www . ldap - account - manager . org / )
2015-01-07 17:16:35 +00:00
Copyright ( C ) 2004 - 2015 Roland Gruber
2005-08-01 11:58:07 +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
*/
/**
* Manages Kolab user accounts .
*
* @ package modules
* @ author Roland Gruber
*/
/**
* Manages Kolab user accounts .
*
* @ package modules
*/
class kolabUser extends baseModule {
2006-08-13 12:58:19 +00:00
2005-08-01 11:58:07 +00:00
/** list of invitation policies */
2007-10-13 17:28:37 +00:00
private $invitationPolicies ;
2005-08-01 11:58:07 +00:00
/**
* Creates a new kolabUser object .
*
* @ param string $scope account type ( user , group , host )
*/
2007-12-28 16:08:56 +00:00
function __construct ( $scope ) {
2008-11-18 19:03:10 +00:00
// call parent constructor
parent :: __construct ( $scope );
2005-08-01 11:58:07 +00:00
// list of invitation policies
$this -> invitationPolicies = array (
'ACT_ALWAYS_ACCEPT' => _ ( 'Always accept' ),
'ACT_ALWAYS_REJECT' => _ ( 'Always reject' ),
'ACT_MANUAL' => _ ( 'Manual' ),
'ACT_REJECT_IF_CONFLICTS' => _ ( 'Reject if conflicts' ),
'ACT_MANUAL_IF_CONFLICTS' => _ ( 'Manual if conflicts' )
);
2008-11-18 19:03:10 +00:00
$this -> autoAddObjectClasses = false ;
2005-08-01 11:58:07 +00:00
}
2014-04-20 13:00:42 +00:00
/**
* Returns true if this module can manage accounts of the current type , otherwise false .
2015-07-11 09:50:00 +00:00
*
2014-04-20 13:00:42 +00:00
* @ return boolean true if module fits
*/
public function can_manage () {
return in_array ( $this -> get_scope (), array ( 'user' ));
}
2005-08-01 11:58:07 +00:00
/**
* Returns meta data that is interpreted by parent class
*
* @ return array array with meta data
2015-07-11 09:50:00 +00:00
*
2008-02-03 14:28:28 +00:00
* @ see baseModule :: get_metaData ()
2005-08-01 11:58:07 +00:00
*/
function get_metaData () {
$return = array ();
2007-11-19 18:42:03 +00:00
// icon
$return [ 'icon' ] = 'kolab.png' ;
2005-08-01 11:58:07 +00:00
// alias name
$return [ " alias " ] = _ ( " Kolab " );
// module dependencies
$return [ 'dependencies' ] = array ( 'depends' => array ( 'inetOrgPerson' ), 'conflicts' => array ());
// LDAP filter
$return [ " ldap_filter " ] = array ( 'or' => " (objectClass=kolabInetOrgPerson) " );
2006-04-05 15:48:27 +00:00
// managed object classes
$return [ 'objectClasses' ] = array ( 'kolabInetOrgPerson' );
2013-11-03 17:17:47 +00:00
if ( $this -> manageMailrecipient ()) {
$return [ 'objectClasses' ][] = 'mailrecipient' ;
}
2006-05-13 08:55:31 +00:00
// managed attributes
2013-08-29 17:55:49 +00:00
$return [ 'attributes' ] = array ( 'alias' , 'mailHost' , 'kolabDelegate' , 'kolabInvitationPolicy' , 'kolabDeleteflag' ,
'kolabAllowSMTPRecipient' , 'kolabAllowSMTPSender' );
2013-11-03 17:17:47 +00:00
if ( $this -> manageMailrecipient ()) {
$return [ 'attributes' ][] = 'mailQuota' ;
}
2005-08-01 11:58:07 +00:00
// profile options
2010-09-20 17:41:20 +00:00
$profileContainer = new htmlTable ();
2012-08-19 12:39:35 +00:00
$profileContainer -> addElement ( new htmlTableExtendedInputField ( _ ( 'Mail server' ), 'kolab_mailHost' , null , 'mailHost' ), true );
2013-12-27 16:26:26 +00:00
$profileContainer -> addElement ( new htmlTableExtendedInputField ( _ ( 'Mailbox quota' ), 'kolab_mailQuota' , null , 'mailQuota' ), true );
2010-09-20 17:41:20 +00:00
$return [ 'profile_options' ] = $profileContainer ;
2005-08-01 11:58:07 +00:00
// profile checks
2012-08-19 12:39:35 +00:00
$return [ 'profile_checks' ][ 'kolab_mailHost' ] = array (
2005-08-01 11:58:07 +00:00
'type' => 'ext_preg' ,
'regex' => 'DNSname' ,
2012-08-19 12:39:35 +00:00
'error_message' => $this -> messages [ 'mailHost' ][ 0 ]);
2013-12-27 16:26:26 +00:00
$return [ 'profile_checks' ][ 'kolab_mailQuota' ] = array (
'type' => 'ext_preg' ,
'regex' => 'digit' ,
'error_message' => $this -> messages [ 'mailQuota' ][ 0 ]);
2013-11-03 17:17:47 +00:00
// config options
$configContainer = new htmlTable ();
$configContainer -> addElement ( new htmlTableExtendedInputCheckbox ( 'kolabUser_mailrecipient' , true , _ ( 'Manage object class "mailrecipient"' ), 'mailrecipient' ), true );
$return [ 'config_options' ][ 'all' ] = $configContainer ;
2008-03-01 12:25:39 +00:00
// self service field settings
$return [ 'selfServiceFieldSettings' ] = array (
'kolabDelegate' => _ ( 'Delegates' ),
2008-03-04 19:47:14 +00:00
'kolabInvitationPolicy' => _ ( 'Invitation policy' )
2008-03-01 12:25:39 +00:00
);
2012-08-18 15:55:43 +00:00
// possible self service read-only fields
2012-08-19 12:39:35 +00:00
$return [ 'selfServiceReadOnlyFields' ] = array ( 'kolabDelegate' , 'kolabInvitationPolicy' );
2005-08-01 11:58:07 +00:00
// help Entries
$return [ 'help' ] = array (
'invPol' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Invitation policy " ), 'attr' => 'kolabInvitationPolicy' ,
2005-08-01 11:58:07 +00:00
" Text " => _ ( " For automatic invitation handling. " )
),
'invPolList' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Invitation policy list " ), 'attr' => 'kolabInvitationPolicy' ,
2005-08-01 11:58:07 +00:00
" Text " => _ ( " This is a comma separated list of invitation policies. " )
),
'delegate' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Delegates " ), 'attr' => 'kolabDelegate' ,
2005-08-01 11:58:07 +00:00
" Text " => _ ( " A user may define who is allowed to act on behalf of herself. This property is checked when using the Kolab smtp daemon (Postfix) to send emails. " )
),
'delegateList' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Delegates " ), 'attr' => 'kolabDelegate' ,
2005-08-01 11:58:07 +00:00
" Text " => _ ( " This is a comma separated list of delegates. " )
),
'alias' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Email alias " ), 'attr' => 'alias' ,
2010-04-02 11:39:09 +00:00
" Text " => _ ( " Email alias for this account. " )
2005-08-01 11:58:07 +00:00
),
'aliasList' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Email alias list " ), 'attr' => 'alias' ,
2005-08-01 11:58:07 +00:00
" Text " => _ ( " This is a comma separated list of eMail aliases. " )
),
2012-08-19 12:39:35 +00:00
'mailHost' => array (
" Headline " => _ ( " Mailbox home server " ), 'attr' => 'mailHost' ,
2005-08-01 11:58:07 +00:00
" Text " => _ ( " The name of the server where the mailbox is located. " )
),
2013-08-29 17:55:49 +00:00
'kolabAllowSMTPRecipient' => array (
2013-12-01 10:02:20 +00:00
" Headline " => _ ( 'Allowed recipients' ), 'attr' => 'kolabAllowSMTPRecipient' ,
2013-08-29 17:55:49 +00:00
" Text " => _ ( 'Describes the allowed or disallowed SMTP recipient addresses for mail sent by this account (e.g. "domain.tld" or "-user@domain.tld").' )
),
'kolabAllowSMTPRecipientList' => array (
2013-12-01 10:02:20 +00:00
" Headline " => _ ( 'Allowed recipients' ), 'attr' => 'kolabAllowSMTPRecipient' ,
2013-08-29 17:55:49 +00:00
" Text " => _ ( 'Describes the allowed or disallowed SMTP recipient addresses for mail sent by this account (e.g. "domain.tld" or "-user@domain.tld").' )
. ' ' . _ ( " Multiple values are separated by semicolon. " )
),
'kolabAllowSMTPSender' => array (
" Headline " => _ ( 'Allowed senders' ), 'attr' => 'kolabAllowSMTPSender' ,
" Text " => _ ( 'Describes the allowed or disallowed SMTP addresses sending mail to this account (e.g. "domain.tld" or "-user@domain.tld").' )
),
'kolabAllowSMTPSenderList' => array (
" Headline " => _ ( 'Allowed senders' ), 'attr' => 'kolabAllowSMTPSender' ,
" Text " => _ ( 'Describes the allowed or disallowed SMTP addresses sending mail to this account (e.g. "domain.tld" or "-user@domain.tld").' )
. ' ' . _ ( " Multiple values are separated by semicolon. " )
),
2013-11-03 17:17:47 +00:00
'mailrecipient' => array (
" Headline " => _ ( 'Manage object class "mailrecipient"' ),
" Text " => _ ( 'Adds the object class "mailrecipient" to all user accounts.' )
),
2013-12-27 16:26:26 +00:00
'mailQuota' => array (
" Headline " => _ ( 'Mailbox quota' ), 'attr' => 'mailQuota' ,
" Text " => _ ( 'The maximum mailbox size in MB.' )
),
2005-08-01 11:58:07 +00:00
'deleteFlag' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Mark for deletion " ), 'attr' => 'kolabDeleteflag' ,
2005-08-01 11:58:07 +00:00
" Text " => _ ( " This will set a special flag on the account which tells Kolabd to remove it. Use this to cleanly delete Kolab accounts (e.g. this removes mail boxes). " )
2013-11-03 17:17:47 +00:00
),
);
2005-08-01 11:58:07 +00:00
// upload fields
$return [ 'upload_columns' ] = array (
array (
'name' => 'kolabUser_invPol' ,
'description' => _ ( 'Invitation policy' ),
'help' => 'invPolList' ,
'example' => 'user@domain:ACT_ALWAYS_ACCEPT,user2@domain:ACT_MANUAL'
),
array (
2012-08-19 12:39:35 +00:00
'name' => 'kolabUser_mailHost' ,
2005-08-01 11:58:07 +00:00
'description' => _ ( 'Mailbox home server' ),
2012-08-19 12:39:35 +00:00
'help' => 'mailHost' ,
2005-08-01 11:58:07 +00:00
'example' => 'localhost' ,
'required' => true
),
2013-12-27 16:26:26 +00:00
array (
'name' => 'kolabUser_mailQuota' ,
'description' => _ ( 'Mailbox quota' ),
'help' => 'mailQuota' ,
'example' => '2000' ,
),
2005-08-01 11:58:07 +00:00
array (
'name' => 'kolabUser_aliases' ,
2010-04-02 11:39:09 +00:00
'description' => _ ( 'Email aliases' ),
2005-08-01 11:58:07 +00:00
'help' => 'aliasList' ,
'example' => 'user@domain,user2@domain'
),
array (
'name' => 'kolabUser_delegates' ,
'description' => _ ( 'Delegates' ),
'help' => 'delegateList' ,
'example' => 'user@domain,user2@domain'
),
2013-08-29 17:55:49 +00:00
array (
'name' => 'kolabUser_kolabAllowSMTPRecipient' ,
2013-12-01 10:02:20 +00:00
'description' => _ ( 'Allowed recipients' ),
2013-08-29 17:55:49 +00:00
'help' => 'kolabAllowSMTPRecipientList' ,
'example' => '.com; -.net' ,
),
array (
'name' => 'kolabUser_kolabAllowSMTPSender' ,
'description' => _ ( 'Allowed senders' ),
'help' => 'kolabAllowSMTPSenderList' ,
'example' => '.com; -.net' ,
),
2005-08-01 11:58:07 +00:00
);
// available PDF fields
$return [ 'PDF_fields' ] = array (
2010-04-05 12:38:23 +00:00
'invPol' => _ ( 'Invitation policy' ),
2012-08-19 12:39:35 +00:00
'mailHost' => _ ( 'Mailbox home server' ),
2013-12-27 16:26:26 +00:00
'mailQuota' => _ ( 'Mailbox quota' ),
2010-04-05 12:38:23 +00:00
'aliases' => _ ( 'Email aliases' ),
'delegate' => _ ( 'Delegates' ),
2013-12-01 10:02:20 +00:00
'kolabAllowSMTPRecipient' => _ ( 'Allowed recipients' ),
2013-08-29 17:55:49 +00:00
'kolabAllowSMTPSender' => _ ( 'Allowed senders' ),
2005-08-01 11:58:07 +00:00
);
return $return ;
}
/**
* This function fills the error message array with messages
*/
function load_Messages () {
$this -> messages [ 'invPol' ][ 0 ] = array ( 'ERROR' , _ ( 'Target of invitation policy is invalid!' )); // third array value is set dynamically
$this -> messages [ 'invPol' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabUser_invPol' , _ ( 'Policy list has invalid format!' ));
2010-04-02 11:39:09 +00:00
$this -> messages [ 'alias' ][ 0 ] = array ( 'ERROR' , _ ( 'Email alias is invalid!' )); // third array value is set dynamically
$this -> messages [ 'alias' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabUser_aliases' , _ ( 'Email alias list has invalid format!' ));
2012-08-19 12:39:35 +00:00
$this -> messages [ 'mailHost' ][ 0 ] = array ( 'ERROR' , _ ( 'Mailbox home server name is invalid!' )); // third array value is set dynamically
$this -> messages [ 'mailHost' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabUser_mailHost' , _ ( 'Mailbox home server name is invalid!' ));
$this -> messages [ 'mailHost' ][ 2 ] = array ( 'ERROR' , _ ( 'Mailbox home server name is empty!' ));
2013-11-03 17:17:47 +00:00
$this -> messages [ 'delegate' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabUser_delegates' , _ ( 'Unknown delegate address: %s' ));
2013-12-07 16:49:23 +00:00
$this -> messages [ 'kolabAllowSMTPRecipient' ][ 0 ] = array ( 'ERROR' , _ ( 'Allowed recipients' ), _ ( 'Please enter a valid recipient expression.' ));
$this -> messages [ 'kolabAllowSMTPRecipient' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabUser_kolabAllowSMTPRecipient' , _ ( 'Please enter a valid recipient expression.' ));
2013-08-29 17:55:49 +00:00
$this -> messages [ 'kolabAllowSMTPSender' ][ 0 ] = array ( 'ERROR' , _ ( 'Allowed senders' ), _ ( 'Please enter a valid sender expression.' ));
$this -> messages [ 'kolabAllowSMTPSender' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabUser_kolabAllowSMTPSender' , _ ( 'Please enter a valid sender expression.' ));
2013-12-27 16:26:26 +00:00
$this -> messages [ 'mailQuota' ][ 0 ] = array ( 'ERROR' , _ ( 'Mailbox quota' ), _ ( 'Please enter a number.' ));
$this -> messages [ 'mailQuota' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabUser_mailQuota' , _ ( 'Please enter a number.' ));
2005-08-01 11:58:07 +00:00
}
2006-08-13 12:58:19 +00:00
2005-08-01 11:58:07 +00:00
/**
2007-11-03 14:17:19 +00:00
* Returns the HTML meta data for the main account page .
2015-07-11 09:50:00 +00:00
*
2010-09-20 17:41:20 +00:00
* @ return htmlElement HTML meta data
2007-11-03 14:17:19 +00:00
*/
2006-08-13 12:58:19 +00:00
function display_html_attributes () {
2010-09-20 17:41:20 +00:00
$return = new htmlTable ();
2008-11-18 19:03:10 +00:00
if ( isset ( $this -> attributes [ 'objectClass' ]) && in_array ( 'kolabInetOrgPerson' , $this -> attributes [ 'objectClass' ])) {
$attrsI = $this -> getAccountContainer () -> getAccountModule ( 'inetOrgPerson' ) -> getAttributes ();
if ( $this -> getAccountContainer () -> isNewAccount ) {
if ( $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) != null ) {
$attrsP = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
if ( ! isset ( $attrsP [ 'userPassword' ][ 0 ]) || ( $attrsP [ 'userPassword' ][ 0 ] == '' )) {
2010-09-20 17:41:20 +00:00
$message = new htmlStatusMessage ( 'ERROR' , _ ( " Please enter a user password. " ));
$message -> colspan = 5 ;
$return -> addElement ( $message , true );
2008-11-18 19:03:10 +00:00
}
2006-06-28 15:10:02 +00:00
}
2009-10-10 12:53:41 +00:00
elseif ( ! isset ( $attrsI [ 'userPassword' ][ 0 ]) || ( $attrsI [ 'userPassword' ][ 0 ] == '' )) {
2010-09-20 17:41:20 +00:00
$message = new htmlStatusMessage ( 'ERROR' , _ ( " Please enter a user password. " ));
$message -> colspan = 5 ;
$return -> addElement ( $message , true );
2006-06-28 15:10:02 +00:00
}
2005-08-16 12:06:13 +00:00
}
2012-08-19 12:39:35 +00:00
if ( ! isset ( $attrsI [ 'mail' ][ 0 ])) {
2010-09-20 17:41:20 +00:00
$message = new htmlStatusMessage ( 'ERROR' , _ ( " Please enter an email address on this page: %s " ), '' , array ( $this -> getAccountContainer () -> getAccountModule ( 'inetOrgPerson' ) -> get_alias ()));
$message -> colspan = 5 ;
$return -> addElement ( $message , true );
2008-11-18 19:03:10 +00:00
}
// check if account is marked for deletion
if ( isset ( $this -> attributes [ 'kolabDeleteflag' ])) {
2010-09-20 17:41:20 +00:00
$return -> addElement ( new htmlOutputText ( _ ( 'This account is marked for deletion.' )));
2008-11-18 19:03:10 +00:00
return $return ;
}
// mailbox server
2012-08-19 12:39:35 +00:00
if ( ! isset ( $this -> orig [ 'mailHost' ][ 0 ])) { // value currently not set
2013-11-02 11:08:04 +00:00
$this -> addSimpleInputTextField ( $return , 'mailHost' , _ ( 'Mailbox home server' ), true );
2008-11-18 19:03:10 +00:00
}
else { // input is unchangable when set
2013-08-29 17:55:49 +00:00
$return -> addElement ( new htmlOutputText ( _ ( 'Mailbox home server' )));
$return -> addElement ( new htmlOutputText ( $this -> attributes [ 'mailHost' ][ 0 ]));
$return -> addElement ( new htmlHelpLink ( 'mailHost' ), true );
2012-08-19 12:39:35 +00:00
}
2013-12-27 16:26:26 +00:00
// mailbox quota
if ( $this -> manageMailrecipient ()) {
$mailQuota = '' ;
if ( ! empty ( $this -> attributes [ 'mailQuota' ][ 0 ])) {
$mailQuota = $this -> attributes [ 'mailQuota' ][ 0 ] / 1024 ;
}
$mailQuotaField = new htmlTableExtendedInputField ( _ ( 'Mailbox quota' ), 'mailQuota' , $mailQuota , 'mailQuota' );
$mailQuotaField -> setValidationRule ( htmlElement :: VALIDATE_NUMERIC );
$return -> addElement ( $mailQuotaField , true );
}
2008-11-18 19:03:10 +00:00
// invitation policies
2010-09-20 17:41:20 +00:00
$return -> addElement ( new htmlSubTitle ( _ ( 'Invitation policy' )), true );
$invitationContainer = new htmlTable ();
2013-08-29 17:55:49 +00:00
$invitationContainer -> colspan = 3 ;
2008-11-18 19:03:10 +00:00
// default invitation policy
$defaultInvPol = $this -> invitationPolicies [ 'ACT_MANUAL' ];
2010-09-20 17:41:20 +00:00
if ( isset ( $this -> attributes [ 'kolabInvitationPolicy' ])) {
for ( $i = 0 ; $i < sizeof ( $this -> attributes [ 'kolabInvitationPolicy' ]); $i ++ ) {
$parts = explode ( " : " , $this -> attributes [ 'kolabInvitationPolicy' ][ $i ]);
if ( sizeof ( $parts ) == 1 ) {
$defaultInvPol = $this -> invitationPolicies [ $this -> attributes [ 'kolabInvitationPolicy' ][ $i ]];
unset ( $this -> attributes [ 'kolabInvitationPolicy' ][ $i ]);
$this -> attributes [ 'kolabInvitationPolicy' ] = array_values ( $this -> attributes [ 'kolabInvitationPolicy' ]);
break ;
}
2008-11-18 19:03:10 +00:00
}
2005-08-01 11:58:07 +00:00
}
2010-09-20 17:41:20 +00:00
$invitationContainer -> addElement ( new htmlTableExtendedSelect ( 'defaultInvPol' , array_values ( $this -> invitationPolicies ), array ( $defaultInvPol ), _ ( 'Anyone' ), 'invPol' ), true );
2008-11-18 19:03:10 +00:00
// other invitation policies
2010-09-20 17:41:20 +00:00
if ( isset ( $this -> attributes [ 'kolabInvitationPolicy' ])) {
for ( $i = 0 ; $i < sizeof ( $this -> attributes [ 'kolabInvitationPolicy' ]); $i ++ ) {
$parts = explode ( " : " , $this -> attributes [ 'kolabInvitationPolicy' ][ $i ]);
if ( sizeof ( $parts ) == 2 ) {
$invitationContainer -> addElement ( new htmlInputField ( 'invPol1' . $i , $parts [ 0 ]));
$invitationContainer -> addElement ( new htmlSelect ( 'invPol2' . $i , array_values ( $this -> invitationPolicies ), array ( $this -> invitationPolicies [ $parts [ 1 ]])));
$invitationContainer -> addElement ( new htmlButton ( 'delInvPol' . $i , 'del.png' , true ));
$invitationContainer -> addElement ( new htmlHelpLink ( 'invPol' ), true );
}
2008-11-18 19:03:10 +00:00
}
2005-08-01 11:58:07 +00:00
}
2008-11-18 19:03:10 +00:00
// input box for new invitation policy
2010-09-20 17:41:20 +00:00
$invitationContainer -> addElement ( new htmlInputField ( 'invPol1' , '' ));
$invitationContainer -> addElement ( new htmlSelect ( 'invPol2' , array_values ( $this -> invitationPolicies )));
$invitationContainer -> addElement ( new htmlButton ( 'addInvPol' , 'add.png' , true ));
$invitationContainer -> addElement ( new htmlHelpLink ( 'invPol' ), true );
$return -> addElement ( $invitationContainer , true );
2008-11-18 19:03:10 +00:00
// mail aliases
2010-09-20 17:41:20 +00:00
$return -> addElement ( new htmlSubTitle ( _ ( 'Email aliases' )), true );
2013-12-17 20:24:13 +00:00
$this -> addMultiValueInputTextField ( $return , 'alias' , null );
2008-11-18 19:03:10 +00:00
// delegates
2010-09-20 17:41:20 +00:00
$delegates = searchLDAPByAttribute ( 'mail' , '*' , 'inetOrgPerson' , array ( 'mail' ), array ( 'user' ));
2010-08-09 17:38:49 +00:00
for ( $i = 0 ; $i < sizeof ( $delegates ); $i ++ ) {
$delegates [ $i ] = $delegates [ $i ][ 'mail' ][ 0 ];
2005-08-01 11:58:07 +00:00
}
2010-08-09 17:38:49 +00:00
sort ( $delegates );
2010-09-20 17:41:20 +00:00
$return -> addElement ( new htmlSubTitle ( _ ( 'Delegates' )), true );
$delegatesContainer = new htmlTable ();
2013-08-29 17:55:49 +00:00
$delegatesContainer -> colspan = 3 ;
2010-07-03 12:31:55 +00:00
if ( isset ( $this -> attributes [ 'kolabDelegate' ])) {
for ( $i = 0 ; $i < sizeof ( $this -> attributes [ 'kolabDelegate' ]); $i ++ ) {
2010-09-20 17:41:20 +00:00
$delegatesContainer -> addElement ( new htmlSelect ( 'delegate' . $i , $delegates , array ( $this -> attributes [ 'kolabDelegate' ][ $i ])));
$delegatesContainer -> addElement ( new htmlButton ( 'delDelegate' . $i , 'del.png' , true ));
2013-11-03 17:17:47 +00:00
if ( $i == 0 ) {
$delegatesContainer -> addElement ( new htmlHelpLink ( 'delegate' ));
}
$delegatesContainer -> addNewLine ();
2010-07-03 12:31:55 +00:00
}
2008-11-18 19:03:10 +00:00
}
// input box for new delegate
2010-09-20 17:41:20 +00:00
$delegatesContainer -> addElement ( new htmlSelect ( 'delegate' , $delegates ));
$delegatesContainer -> addElement ( new htmlButton ( 'addDelegate' , 'add.png' , true ));
2013-11-03 17:17:47 +00:00
if ( empty ( $this -> attributes [ 'kolabDelegate' ])) {
$delegatesContainer -> addElement ( new htmlHelpLink ( 'delegate' ));
}
2010-09-20 17:41:20 +00:00
$return -> addElement ( $delegatesContainer , true );
2013-08-29 17:55:49 +00:00
$return -> addElement ( new htmlSubTitle ( _ ( 'Options' )), true );
2013-12-01 10:02:20 +00:00
// allowed recipients
$this -> addMultiValueInputTextField ( $return , 'kolabAllowSMTPRecipient' , _ ( 'Allowed recipients' ));
2013-08-29 17:55:49 +00:00
// allowed senders
$this -> addMultiValueInputTextField ( $return , 'kolabAllowSMTPSender' , _ ( 'Allowed senders' ));
2008-11-18 19:03:10 +00:00
// delete flag
if ( ! $this -> getAccountContainer () -> isNewAccount ) {
2010-09-20 17:41:20 +00:00
$deleteContainer = new htmlTable ();
$deleteContainer -> addElement ( new htmlSpacer ( null , '20px' ), true );
$deleteContainer -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'deleteUser' , 'open' , _ ( 'Mark account for deletion' )));
$deleteContainer -> addElement ( new htmlHelpLink ( 'deleteFlag' ));
$return -> addElement ( $deleteContainer );
2008-11-18 19:03:10 +00:00
}
2005-08-01 11:58:07 +00:00
}
2008-11-18 19:03:10 +00:00
else {
2010-09-20 17:41:20 +00:00
$return -> addElement ( new htmlButton ( 'addObjectClass' , _ ( 'Add Kolab extension' )));
2005-08-01 11:58:07 +00:00
}
return $return ;
}
/**
2005-09-07 12:58:34 +00:00
* Processes user input of the primary module page .
* It checks if all input values are correct and updates the associated LDAP attributes .
2005-08-01 11:58:07 +00:00
*
2005-09-07 12:58:34 +00:00
* @ return array list of info / error messages
2005-08-01 11:58:07 +00:00
*/
2006-08-13 12:58:19 +00:00
function process_attributes () {
2006-05-16 15:38:55 +00:00
$errors = array ();
2010-09-20 17:41:20 +00:00
if ( isset ( $_POST [ 'addObjectClass' ])) {
2008-11-18 19:03:10 +00:00
$this -> attributes [ 'objectClass' ][] = 'kolabInetOrgPerson' ;
2013-11-03 17:17:47 +00:00
if ( $this -> manageMailrecipient ()) {
$this -> attributes [ 'objectClass' ][] = 'mailrecipient' ;
}
2005-08-01 11:58:07 +00:00
}
2008-11-18 19:03:10 +00:00
else {
2010-05-19 19:22:29 +00:00
if ( isset ( $_POST [ 'form_subpage_kolabUser_deleteUser_open' ])) return array ();
2008-11-18 19:03:10 +00:00
$this -> attributes [ 'kolabInvitationPolicy' ] = array ();
// mailbox server
2012-08-19 12:39:35 +00:00
if ( isset ( $_POST [ 'mailHost' ])) {
if ( $_POST [ 'mailHost' ] == " " ) {
$errors [] = $this -> messages [ 'mailHost' ][ 2 ];
2008-11-18 19:03:10 +00:00
}
2012-08-19 12:39:35 +00:00
elseif ( get_preg ( $_POST [ 'mailHost' ], 'DNSname' )) {
$this -> attributes [ 'mailHost' ][ 0 ] = $_POST [ 'mailHost' ];
2008-11-18 19:03:10 +00:00
}
else {
2012-08-19 12:39:35 +00:00
$message = $this -> messages [ 'mailHost' ][ 0 ];
$message [] = $_POST [ 'mailHost' ];
2008-11-18 19:03:10 +00:00
$errors [] = $message ;
}
2005-08-01 11:58:07 +00:00
}
2008-11-18 19:03:10 +00:00
// check old invitation policies
$policies = array_flip ( $this -> invitationPolicies );
$targets = array ();
$i = 0 ;
while ( isset ( $_POST [ 'invPol1' . $i ])) {
if ( isset ( $_POST [ 'delInvPol' . $i ])) {
$i ++ ;
continue ;
}
if ( isset ( $_POST [ 'invPol2' . $i ]) && ( $_POST [ 'invPol1' . $i ] != " " ) && ! in_array ( $_POST [ 'invPol1' . $i ], $targets )) {
$targets [] = $_POST [ 'invPol1' . $i ];
// check invitation policy
if ( ! get_preg ( $_POST [ 'invPol1' . $i ], 'email' )) {
$message = $this -> messages [ 'invPol' ][ 0 ];
$message [] = $_POST [ 'invPol1' . $i ];
$errors [] = $message ;
}
else {
$this -> attributes [ 'kolabInvitationPolicy' ][] = $_POST [ 'invPol1' . $i ] . ':' . $policies [ $_POST [ 'invPol2' . $i ]];
}
}
2005-08-01 11:58:07 +00:00
$i ++ ;
}
2008-11-18 19:03:10 +00:00
// check new invitation policy
if ( isset ( $_POST [ 'invPol1' ]) && ( $_POST [ 'invPol1' ] != " " ) && ! in_array ( $_POST [ 'invPol1' ], $targets )) {
// check new invitation policy
if ( ! get_preg ( $_POST [ 'invPol1' ], 'email' )) {
2005-08-01 11:58:07 +00:00
$message = $this -> messages [ 'invPol' ][ 0 ];
2008-11-18 19:03:10 +00:00
$message [] = $_POST [ 'invPol1' ];
2006-08-16 17:42:35 +00:00
$errors [] = $message ;
2005-08-01 11:58:07 +00:00
}
else {
2008-11-18 19:03:10 +00:00
$this -> attributes [ 'kolabInvitationPolicy' ][] = $_POST [ 'invPol1' ] . ':' . $policies [ $_POST [ 'invPol2' ]];
2005-08-01 11:58:07 +00:00
}
}
2008-11-18 19:03:10 +00:00
// default invitation policy
if ( isset ( $_POST [ 'defaultInvPol' ]) && ( $_POST [ 'defaultInvPol' ] != " " )) {
$this -> attributes [ 'kolabInvitationPolicy' ][] = $policies [ $_POST [ 'defaultInvPol' ]];
2005-08-01 11:58:07 +00:00
}
2013-11-02 11:08:04 +00:00
// mail aliases
$this -> processMultiValueInputTextField ( 'alias' , $errors , 'email' );
2008-11-18 19:03:10 +00:00
// check old delegates
$this -> attributes [ 'kolabDelegate' ] = array ();
$i = 0 ;
while ( isset ( $_POST [ 'delegate' . $i ])) {
if ( isset ( $_POST [ 'delDelegate' . $i ])) {
$i ++ ;
continue ;
}
$this -> attributes [ 'kolabDelegate' ][] = $_POST [ 'delegate' . $i ];
2005-08-01 11:58:07 +00:00
$i ++ ;
}
2008-11-18 19:03:10 +00:00
// check new delegate
if ( isset ( $_POST [ 'addDelegate' ]) && ( $_POST [ 'delegate' ] != " " )) {
$this -> attributes [ 'kolabDelegate' ][] = $_POST [ 'delegate' ];
2005-08-01 11:58:07 +00:00
}
2008-11-18 19:03:10 +00:00
$this -> attributes [ 'kolabDelegate' ] = array_unique ( $this -> attributes [ 'kolabDelegate' ]);
2013-12-01 10:02:20 +00:00
// allowed recipients
2013-08-29 17:55:49 +00:00
$this -> processMultiValueInputTextField ( 'kolabAllowSMTPRecipient' , $errors , 'kolabEmailPrefix' );
// allowed senders
$this -> processMultiValueInputTextField ( 'kolabAllowSMTPSender' , $errors , 'kolabEmailPrefix' );
2013-12-27 16:26:26 +00:00
// mailbox quota
if ( $this -> manageMailrecipient ()) {
if ( ! empty ( $_POST [ 'mailQuota' ]) && ! get_preg ( $_POST [ 'mailQuota' ], 'digit' )) {
$errors [] = $this -> messages [ 'mailQuota' ][ 0 ];
}
else {
$mailQuota = array ();
if ( ! empty ( $_POST [ 'mailQuota' ])) {
$mailQuota = array ( $_POST [ 'mailQuota' ] * 1024 );
}
$this -> attributes [ 'mailQuota' ] = $mailQuota ;
}
}
2005-08-01 11:58:07 +00:00
}
2006-05-16 15:38:55 +00:00
return $errors ;
2005-08-01 11:58:07 +00:00
}
/**
2010-09-20 17:41:20 +00:00
* This function will create the meta HTML code to show a page to mark an account for deletion .
2015-07-11 09:50:00 +00:00
*
2010-09-20 17:41:20 +00:00
* @ return htmlElement HTML meta data
2005-08-01 11:58:07 +00:00
*/
2006-08-13 12:58:19 +00:00
function display_html_deleteUser () {
2010-09-20 17:41:20 +00:00
$return = new htmlTable ();
$message = new htmlOutputText ( _ ( 'Do you really want to mark this account for deletion?' ));
$message -> colspan = 2 ;
$return -> addElement ( $message , true );
$return -> addElement ( new htmlSpacer ( null , '10px' ), true );
$return -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'confirm' , _ ( 'Mark account for deletion' )));
$return -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'cancel' , _ ( 'Cancel' )));
2005-08-01 11:58:07 +00:00
return $return ;
}
2006-08-13 12:58:19 +00:00
2005-08-01 11:58:07 +00:00
/**
* Write variables into object and do some regex checks
*/
2006-08-13 12:58:19 +00:00
function process_deleteUser () {
2010-09-20 17:41:20 +00:00
if ( isset ( $_POST [ 'form_subpage_kolabUser_attributes_confirm' ])) {
2005-08-01 11:58:07 +00:00
// set delete flag
2012-08-19 12:39:35 +00:00
$this -> attributes [ 'kolabDeleteflag' ][ 0 ] = $this -> attributes [ 'mailHost' ][ 0 ];
2005-08-01 11:58:07 +00:00
}
}
/**
* This function returns true if all needed settings are done .
2005-08-16 12:06:13 +00:00
*
* @ return true , if account can be saved
2005-08-01 11:58:07 +00:00
*/
function module_complete () {
2008-11-18 19:03:10 +00:00
if ( isset ( $this -> attributes [ 'objectClass' ]) && in_array ( 'kolabInetOrgPerson' , $this -> attributes [ 'objectClass' ])) {
$attrsI = $this -> getAccountContainer () -> getAccountModule ( 'inetOrgPerson' ) -> getAttributes ();
if ( ! $attrsI [ 'mail' ][ 0 ]) return false ;
if ( $this -> getAccountContainer () -> isNewAccount ) {
if ( $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) != null ) {
2008-12-30 16:41:39 +00:00
$attrsP = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
2008-11-18 19:03:10 +00:00
if ( ! $attrsP [ 'userPassword' ][ 0 ]) return false ;
}
2009-10-10 12:53:41 +00:00
elseif ( ! $attrsI [ 'userPassword' ][ 0 ]) {
return false ;
2008-11-18 19:03:10 +00:00
}
2006-06-28 15:10:02 +00:00
}
2005-08-01 11:58:07 +00:00
}
2006-05-16 15:38:55 +00:00
return true ;
2005-08-01 11:58:07 +00:00
}
2006-08-13 12:58:19 +00:00
2010-10-02 12:30:35 +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 )
2010-10-02 12:30:35 +00:00
*/
function save_attributes () {
if ( ! in_array ( 'kolabInetOrgPerson' , $this -> attributes [ 'objectClass' ]) && ! in_array ( 'kolabInetOrgPerson' , $this -> orig [ 'objectClass' ])) {
// skip saving if the extension was not added/modified
return array ();
}
return $this -> getAccountContainer () -> save_module_attributes ( $this -> attributes , $this -> orig );
}
2013-12-27 16:26:26 +00:00
/**
* Loads the values of an account profile into internal variables .
*
* @ param array $profile hash array with profile values ( identifier => value )
*/
function load_profile ( $profile ) {
// profile mappings in meta data
parent :: load_profile ( $profile );
// mail server
if ( ! isset ( $this -> orig [ 'mailHost' ][ 0 ]) && ! empty ( $profile [ 'kolab_mailHost' ][ 0 ])) {
$this -> attributes [ 'mailHost' ][ 0 ] = $profile [ 'kolab_mailHost' ][ 0 ];
}
// mailbox quota
if ( ! empty ( $profile [ 'kolab_mailQuota' ][ 0 ])) {
$this -> attributes [ 'mailQuota' ][ 0 ] = $profile [ 'kolab_mailQuota' ][ 0 ] * 1024 ;
}
}
2005-08-01 11:58:07 +00:00
/**
* In this function the LDAP account is built up .
*
* @ param array $rawAccounts list of hash arrays ( name => value ) from user input
* @ param array $ids list of IDs for column position ( e . g . " posixAccount_uid " => 5 )
2012-07-15 12:05:47 +00:00
* @ param array $partialAccounts list of hash arrays ( name => value ) which are later added to LDAP
2010-02-15 20:21:44 +00:00
* @ param array $selectedModules list of selected account modules
2005-08-01 11:58:07 +00:00
* @ return array list of error messages if any
*/
2010-02-15 20:21:44 +00:00
function build_uploadAccounts ( $rawAccounts , $ids , & $partialAccounts , $selectedModules ) {
2005-08-01 11:58:07 +00:00
$messages = array ();
2010-08-09 17:38:49 +00:00
$delegates = searchLDAPByAttribute ( null , null , 'inetOrgPerson' , array ( 'mail' ), array ( 'user' ));
for ( $d = 0 ; $d < sizeof ( $delegates ); $d ++ ) {
2010-11-20 19:57:32 +00:00
if ( isset ( $delegates [ $d ][ 'mail' ][ 0 ])) {
$delegates [ $d ] = $delegates [ $d ][ 'mail' ][ 0 ];
}
2010-08-09 17:38:49 +00:00
}
2005-08-01 11:58:07 +00:00
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
// add object class
2013-11-03 17:17:47 +00:00
if ( ! in_array ( " kolabInetOrgPerson " , $partialAccounts [ $i ][ 'objectClass' ])) {
$partialAccounts [ $i ][ 'objectClass' ][] = " kolabInetOrgPerson " ;
}
if ( $this -> manageMailrecipient () && ! in_array ( " mailrecipient " , $partialAccounts [ $i ][ 'objectClass' ])) {
$partialAccounts [ $i ][ 'objectClass' ][] = " mailrecipient " ;
}
2005-08-01 11:58:07 +00:00
// mailbox server
2014-04-13 16:59:56 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'kolabUser_mailHost' , 'mailHost' ,
'DNSname' , $this -> messages [ 'mailHost' ][ 1 ], $messages );
2013-12-27 16:26:26 +00:00
// mailbox quota
if ( ! empty ( $rawAccounts [ $i ][ $ids [ 'kolabUser_mailQuota' ]])) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'kolabUser_mailQuota' ]], 'digit' )) {
$partialAccounts [ $i ][ 'mailQuota' ] = $rawAccounts [ $i ][ $ids [ 'kolabUser_mailQuota' ]] * 1024 ;
}
else {
$errMsg = $this -> messages [ 'mailQuota' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$messages [] = $errMsg ;
}
}
2005-08-01 11:58:07 +00:00
// add invitation policies
if ( $rawAccounts [ $i ][ $ids [ 'kolabUser_invPol' ]] != " " ) {
$pols = explode ( ',' , $rawAccounts [ $i ][ $ids [ 'kolabUser_invPol' ]]);
// check format
$policies = array_keys ( $this -> invitationPolicies );
$defaultFound = false ;
for ( $p = 0 ; $p < sizeof ( $pols ); $p ++ ) {
2009-08-14 20:18:08 +00:00
$parts = explode ( " : " , $pols [ $p ]);
2005-08-01 11:58:07 +00:00
// default policy
if ( sizeof ( $parts ) == 1 ) {
if ( ! $defaultFound && get_preg ( $parts [ 0 ], 'email' )) {
$partialAccounts [ $i ][ 'kolabInvitationPolicy' ][] = $parts [ 0 ];
}
else {
$errMsg = $this -> messages [ 'invPol' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$messages [] = $errMsg ;
}
$defaultFound = true ;
}
// additional policies
elseif ( sizeof ( $parts ) == 2 ) {
if ( get_preg ( $parts [ 0 ], 'email' ) && in_array ( $parts [ 1 ], $policies )) {
$partialAccounts [ $i ][ 'kolabInvitationPolicy' ][] = $pols [ $p ];
}
else {
$errMsg = $this -> messages [ 'invPol' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$messages [] = $errMsg ;
}
}
// invalid format
else {
$errMsg = $this -> messages [ 'invPol' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$messages [] = $errMsg ;
}
}
}
// add mail aliases
2015-08-16 08:47:48 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'kolabUser_aliases' , 'alias' , 'email' , $this -> messages [ 'alias' ][ 1 ], $messages , '/,[ ]*/' );
2005-08-01 11:58:07 +00:00
// add delegates
if ( $rawAccounts [ $i ][ $ids [ 'kolabUser_delegates' ]] != " " ) {
$newDelegates = explode ( ',' , $rawAccounts [ $i ][ $ids [ 'kolabUser_delegates' ]]);
// check format
for ( $d = 0 ; $d < sizeof ( $newDelegates ); $d ++ ) {
if ( in_array ( $newDelegates [ $d ], $delegates )) {
$partialAccounts [ $i ][ 'kolabDelegate' ][] = $newDelegates [ $d ];
}
// invalid format
else {
$errMsg = $this -> messages [ 'delegate' ][ 0 ];
2010-08-09 17:38:49 +00:00
array_push ( $errMsg , array ( $i , $newDelegates [ $d ]));
2005-08-01 11:58:07 +00:00
$messages [] = $errMsg ;
}
}
}
2013-08-29 17:55:49 +00:00
// allowed recipients
2015-08-16 08:47:48 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'kolabUser_kolabAllowSMTPRecipient' , 'kolabAllowSMTPRecipient' , 'kolabEmailPrefix' , $this -> messages [ 'kolabAllowSMTPRecipient' ][ 1 ], $messages , '/;[ ]*/' );
2013-08-29 17:55:49 +00:00
// allowed senders
2015-08-16 08:47:48 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'kolabUser_kolabAllowSMTPSender' , 'kolabAllowSMTPSender' , 'kolabEmailPrefix' , $this -> messages [ 'kolabAllowSMTPSender' ][ 1 ], $messages , '/;[ ]*/' );
2005-08-01 11:58:07 +00:00
}
return $messages ;
}
/**
2015-01-07 17:16:35 +00:00
* Returns a list of possible PDF entries for this account .
*
* @ param array $pdfKeys list of PDF keys that are included in document
* @ return list of PDF entries ( array ( < PDF key > => < PDF lines > ))
*/
function get_pdfEntries ( $pdfKeys ) {
2005-08-01 11:58:07 +00:00
$return = array ();
2013-05-06 19:16:47 +00:00
$this -> addSimplePDFField ( $return , 'mailHost' , _ ( 'Mailbox home server' ));
2005-08-01 11:58:07 +00:00
// invitation policies
2011-01-09 16:20:21 +00:00
if ( isset ( $this -> attributes [ 'kolabInvitationPolicy' ][ 0 ])) {
2005-08-01 11:58:07 +00:00
// find default policy
$default = " " ;
for ( $i = 0 ; $i < sizeof ( $this -> attributes [ 'kolabInvitationPolicy' ]); $i ++ ) {
if ( ! strpos ( $this -> attributes [ 'kolabInvitationPolicy' ][ $i ], " : " )) {
$default = $this -> attributes [ 'kolabInvitationPolicy' ][ $i ];
break ;
}
}
2015-07-11 09:50:00 +00:00
$pdfTable = new PDFTable ( _ ( 'Invitation policy' ));
$pdfRow = new PDFTableRow ();
$pdfRow -> cells [] = new PDFTableCell ( _ ( 'Anyone' ) . " : " . $this -> invitationPolicies [ $default ]);
$pdfTable -> rows [] = $pdfRow ;
2005-08-01 11:58:07 +00:00
for ( $i = 0 ; $i < sizeof ( $this -> attributes [ 'kolabInvitationPolicy' ]); $i ++ ) {
2009-08-14 20:18:08 +00:00
$parts = explode ( ':' , $this -> attributes [ 'kolabInvitationPolicy' ][ $i ]);
2005-08-01 11:58:07 +00:00
if ( sizeof ( $parts ) == 2 ) {
2015-07-11 09:50:00 +00:00
$pdfRow = new PDFTableRow ();
$pdfRow -> cells [] = new PDFTableCell ( $parts [ 0 ] . " : " . $this -> invitationPolicies [ $parts [ 1 ]]);
$pdfTable -> rows [] = $pdfRow ;
2005-08-01 11:58:07 +00:00
}
}
2015-07-11 09:50:00 +00:00
$this -> addPDFTable ( $return , 'invPol' , $pdfTable );
2005-08-01 11:58:07 +00:00
}
2013-05-06 19:16:47 +00:00
$this -> addSimplePDFField ( $return , 'aliases' , _ ( 'Email aliases' ), 'alias' );
$this -> addSimplePDFField ( $return , 'delegate' , _ ( 'Delegates' ), 'kolabDelegate' );
2013-12-01 10:02:20 +00:00
$this -> addSimplePDFField ( $return , 'kolabAllowSMTPRecipient' , _ ( 'Allowed recipients' ));
2013-08-29 17:55:49 +00:00
$this -> addSimplePDFField ( $return , 'kolabAllowSMTPSender' , _ ( 'Allowed senders' ));
2013-12-27 16:26:26 +00:00
$mailQuota = '' ;
if ( ! empty ( $this -> attributes [ 'mailQuota' ][ 0 ])) {
$mailQuota = ( $this -> attributes [ 'mailQuota' ][ 0 ] / 1024 ) . 'MB' ;
}
2015-03-11 20:50:37 +00:00
$this -> addPDFKeyValue ( $return , 'mailQuota' , _ ( 'Mailbox quota' ), $mailQuota );
2005-08-01 11:58:07 +00:00
return $return ;
}
2008-03-01 12:25:39 +00:00
/**
* Returns the meta HTML code for each input field .
* format : array ( < field1 > => array ( < META HTML > ), ... )
* It is not possible to display help links .
*
* @ param array $fields list of active fields
2011-08-20 17:59:36 +00:00
* @ param array $attributes attributes of LDAP account
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
2015-08-09 07:57:56 +00:00
* @ return array list of meta HTML elements ( field name => htmlResponsiveRow )
2008-03-01 12:25:39 +00:00
*/
2012-08-18 15:55:43 +00:00
function getSelfServiceOptions ( $fields , $attributes , $passwordChangeOnly , $readOnlyFields ) {
2012-02-08 17:55:00 +00:00
if ( $passwordChangeOnly ) {
return array (); // no Kolab fields as long no LDAP content can be read
}
2008-03-01 12:25:39 +00:00
if ( ! in_array ( 'kolabInetOrgPerson' , $attributes [ 'objectClass' ])) {
return array ();
}
$return = array ();
2008-03-04 19:47:14 +00:00
// delegates
2008-03-01 12:25:39 +00:00
if ( in_array ( 'kolabDelegate' , $fields )) {
$delegates = array ();
2009-10-28 16:36:24 +00:00
$sr = @ ldap_search ( $_SESSION [ 'ldapHandle' ], escapeDN ( $this -> selfServiceSettings -> LDAPSuffix ), '(&(objectClass=inetOrgPerson)(mail=*))' , array ( 'mail' ), 0 , 0 , 0 , LDAP_DEREF_NEVER );
2008-03-01 12:25:39 +00:00
if ( $sr ) {
$result = ldap_get_entries ( $_SESSION [ 'ldapHandle' ], $sr );
2011-05-21 10:58:22 +00:00
cleanLDAPResult ( $result );
2009-12-19 16:07:10 +00:00
for ( $i = 0 ; $i < sizeof ( $result ); $i ++ ) {
2008-03-01 12:25:39 +00:00
$delegates [] = $result [ $i ][ 'mail' ][ 0 ];
}
}
$delegates = array_unique ( $delegates );
sort ( $delegates );
$kolabDelegate = array ();
if ( isset ( $attributes [ 'kolabDelegate' ])) {
$kolabDelegate = $attributes [ 'kolabDelegate' ];
// do not show existing delegation candidates in selection list
for ( $i = 0 ; $i < sizeof ( $kolabDelegate ); $i ++ ) {
$key = array_search ( $kolabDelegate [ $i ], $delegates );
if ( $key !== false ) {
unset ( $delegates [ $key ]);
}
}
}
$delegates = array_values ( $delegates );
sort ( $kolabDelegate );
$_SESSION [ 'kolabUser_kolabDelegate' ] = $kolabDelegate ;
$delegateFields = array ();
2010-07-03 12:31:55 +00:00
$delegateContainer = new htmlTable ();
2008-03-01 12:25:39 +00:00
for ( $i = 0 ; $i < sizeof ( $kolabDelegate ); $i ++ ) {
2011-12-10 14:44:56 +00:00
$delegateContainer -> addElement ( new htmlOutputText ( $kolabDelegate [ $i ]));
2012-08-18 15:55:43 +00:00
if ( ! in_array ( 'kolabDelegate' , $readOnlyFields )) {
$delegateContainer -> addElement ( new htmlTableExtendedInputCheckbox ( 'delDelegate_' . $i , false , _ ( 'Delete' ), null , false ), true );
}
else {
$delegateContainer -> addNewLine ();
}
}
if ( ! in_array ( 'kolabDelegate' , $readOnlyFields )) {
$delegateContainer -> addElement ( new htmlSelect ( 'new_delegate_value' , $delegates ));
$delegateContainer -> addElement ( new htmlTableExtendedInputCheckbox ( 'new_delegate' , false , _ ( " Add " ), null , false ), true );
2010-07-03 12:31:55 +00:00
}
2013-11-30 15:02:06 +00:00
$delegateLabel = new htmlOutputText ( $this -> getSelfServiceLabel ( 'kolabDelegate' , _ ( 'Delegates' )));
2015-08-09 07:57:56 +00:00
$row = new htmlResponsiveRow ();
$row -> addLabel ( $delegateLabel );
$row -> addField ( $delegateContainer );
$return [ 'kolabDelegate' ] = $row ;
2008-03-01 12:25:39 +00:00
}
2008-03-04 19:47:14 +00:00
// invitation policies
if ( in_array ( 'kolabInvitationPolicy' , $fields )) {
2010-07-03 12:31:55 +00:00
$invitationContainer = new htmlTable ();
2008-03-04 19:47:14 +00:00
// default invitation policy
$defaultInvPol = $this -> invitationPolicies [ 'ACT_MANUAL' ];
for ( $i = 0 ; $i < sizeof ( $attributes [ 'kolabInvitationPolicy' ]); $i ++ ) {
2009-08-14 20:18:08 +00:00
$parts = explode ( " : " , $attributes [ 'kolabInvitationPolicy' ][ $i ]);
2008-03-04 19:47:14 +00:00
if ( sizeof ( $parts ) == 1 ) {
$defaultInvPol = $this -> invitationPolicies [ $attributes [ 'kolabInvitationPolicy' ][ $i ]];
unset ( $attributes [ 'kolabInvitationPolicy' ][ $i ]);
$attributes [ 'kolabInvitationPolicy' ] = array_values ( $attributes [ 'kolabInvitationPolicy' ]);
break ;
}
}
2012-08-18 15:55:43 +00:00
if ( ! in_array ( 'kolabDelegate' , $readOnlyFields )) {
$invitationContainer -> addElement ( new htmlTableExtendedSelect ( 'defaultInvPol' , array_values ( $this -> invitationPolicies ), array ( $defaultInvPol ), _ ( 'Anyone' )), true );
}
else {
$invitationContainer -> addElement ( new htmlOutputText ( _ ( 'Anyone' )));
$invitationContainer -> addElement ( new htmlOutputText ( $defaultInvPol ), true );
}
2008-03-04 19:47:14 +00:00
// other invitation policies
for ( $i = 0 ; $i < sizeof ( $attributes [ 'kolabInvitationPolicy' ]); $i ++ ) {
2009-08-14 20:18:08 +00:00
$parts = explode ( " : " , $attributes [ 'kolabInvitationPolicy' ][ $i ]);
2008-03-04 19:47:14 +00:00
if ( sizeof ( $parts ) == 2 ) {
2012-08-18 15:55:43 +00:00
if ( ! in_array ( 'kolabDelegate' , $readOnlyFields )) {
$invitationContainer -> addElement ( new htmlInputField ( 'invPol1' . $i , $parts [ 0 ]));
$invitationContainer -> addElement ( new htmlSelect ( 'invPol2' . $i , array_values ( $this -> invitationPolicies ), array ( $this -> invitationPolicies [ $parts [ 1 ]])));
$invitationContainer -> addElement ( new htmlTableExtendedInputCheckbox ( 'delInvPol' . $i , false , _ ( " Remove " ), null , false ), true );
}
else {
$invitationContainer -> addElement ( new htmlOutputText ( $parts [ 0 ]));
$invitationContainer -> addElement ( new htmlOutputText ( $this -> invitationPolicies [ $parts [ 1 ]]), true );
}
2008-03-04 19:47:14 +00:00
}
}
// input box for new invitation policy
2012-08-18 15:55:43 +00:00
if ( ! in_array ( 'kolabDelegate' , $readOnlyFields )) {
$invitationContainer -> addElement ( new htmlInputField ( 'invPol1' , '' ));
$invitationContainer -> addElement ( new htmlSelect ( 'invPol2' , array_values ( $this -> invitationPolicies )));
$invitationContainer -> addElement ( new htmlTableExtendedInputCheckbox ( 'addInvPol' , false , _ ( " Add " ), null , false ), true );
}
2013-11-30 15:02:06 +00:00
$invitationLabel = new htmlOutputText ( $this -> getSelfServiceLabel ( 'kolabInvitationPolicy' , _ ( 'Invitation policy' )));
2015-08-09 07:57:56 +00:00
$row = new htmlResponsiveRow ();
$row -> addLabel ( $invitationLabel );
$row -> addField ( $invitationContainer );
$return [ 'kolabInvitationPolicy' ] = $row ;
2008-03-04 19:47:14 +00:00
}
2008-03-01 12:25:39 +00:00
return $return ;
}
/**
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 )
2015-07-11 09:50:00 +00:00
*
2011-02-26 13:14:10 +00:00
* Calling this method does not require the existence of an enclosing { @ link accountContainer } .
2008-03-01 12:25:39 +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 ()))
2008-03-01 12:25:39 +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 ( $passwordChangeOnly ) {
return $return ; // skip processing if only a password change is done
}
2008-12-14 10:18:36 +00:00
if ( ! in_array_ignore_case ( 'kolabInetOrgPerson' , $attributes [ 'objectClass' ])) {
return $return ;
}
2008-03-01 12:25:39 +00:00
$attributeNames = array (); // list of attributes which should be checked for modification
$attributesNew = $attributes ;
// delegates
2012-08-18 15:55:43 +00:00
if ( in_array ( 'kolabDelegate' , $fields ) && ! in_array ( 'kolabDelegate' , $readOnlyFields )) {
2008-03-01 12:25:39 +00:00
$attributeNames [] = 'kolabDelegate' ;
// new delegation
if ( isset ( $_POST [ 'new_delegate' ]) && ( $_POST [ 'new_delegate' ] == 'on' )) {
$attributesNew [ 'kolabDelegate' ][] = $_POST [ 'new_delegate_value' ];
}
// check for deleted delegations
$postKeys = array_keys ( $_POST );
for ( $i = 0 ; $i < sizeof ( $postKeys ); $i ++ ) {
if ( strpos ( $postKeys [ $i ], 'delDelegate_' ) !== false ) {
$sKey = substr ( $postKeys [ $i ], strlen ( 'delDelegate_' ));
$key = array_search ( $_SESSION [ 'kolabUser_kolabDelegate' ][ $sKey ], $attributesNew [ 'kolabDelegate' ]);
if ( $key !== false ) {
unset ( $attributesNew [ 'kolabDelegate' ][ $key ]);
$attributesNew [ 'kolabDelegate' ] = array_values ( $attributesNew [ 'kolabDelegate' ]);
}
}
}
}
2008-03-04 19:47:14 +00:00
// invitation policies
2012-08-18 15:55:43 +00:00
if ( in_array ( 'kolabInvitationPolicy' , $fields ) && ! in_array ( 'kolabInvitationPolicy' , $readOnlyFields )) {
2008-03-04 19:47:14 +00:00
$attributeNames [] = 'kolabInvitationPolicy' ;
$policies = array_flip ( $this -> invitationPolicies );
$attributesNew [ 'kolabInvitationPolicy' ] = array ();
// check old invitation policies
$targets = array ();
$i = 0 ;
while ( isset ( $_POST [ 'invPol1' . $i ])) {
if ( isset ( $_POST [ 'delInvPol' . $i ])) {
$i ++ ;
continue ;
}
if ( isset ( $_POST [ 'invPol2' . $i ]) && ( $_POST [ 'invPol1' . $i ] != " " ) && ! in_array ( $_POST [ 'invPol1' . $i ], $targets )) {
$targets [] = $_POST [ 'invPol1' . $i ];
// check invitation policy
if ( ! get_preg ( $_POST [ 'invPol1' . $i ], 'email' )) {
$message = $this -> messages [ 'invPol' ][ 0 ];
$message [] = $_POST [ 'invPol1' . $i ];
$errors [] = $message ;
}
else {
$attributesNew [ 'kolabInvitationPolicy' ][] = $_POST [ 'invPol1' . $i ] . ':' . $policies [ $_POST [ 'invPol2' . $i ]];
}
}
$i ++ ;
}
// check new invitation policy
if ( isset ( $_POST [ 'invPol1' ]) && ( $_POST [ 'invPol1' ] != " " ) && ! in_array ( $_POST [ 'invPol1' ], $targets )) {
// check new invitation policy
if ( ! get_preg ( $_POST [ 'invPol1' ], 'email' )) {
$message = $this -> messages [ 'invPol' ][ 0 ];
$message [] = $_POST [ 'invPol1' ];
$errors [] = $message ;
}
else {
$attributesNew [ 'kolabInvitationPolicy' ][] = $_POST [ 'invPol1' ] . ':' . $policies [ $_POST [ 'invPol2' ]];
}
}
// default invitation policy
if ( isset ( $_POST [ 'defaultInvPol' ]) && ( $_POST [ 'defaultInvPol' ] != " " )) {
$attributesNew [ 'kolabInvitationPolicy' ][] = $policies [ $_POST [ 'defaultInvPol' ]];
}
}
2008-03-01 12:25:39 +00:00
// find differences
for ( $i = 0 ; $i < sizeof ( $attributeNames ); $i ++ ) {
$attrName = $attributeNames [ $i ];
if ( isset ( $attributes [ $attrName ]) && ! isset ( $attributesNew [ $attrName ])) {
$return [ 'del' ][ $attrName ] = $attributes [ $attrName ];
}
elseif ( ! isset ( $attributes [ $attrName ]) && isset ( $attributesNew [ $attrName ])) {
$return [ 'add' ][ $attrName ] = $attributesNew [ $attrName ];
}
else {
2010-06-16 17:22:47 +00:00
if ( isset ( $attributes [ $attrName ])) {
for ( $a = 0 ; $a < sizeof ( $attributes [ $attrName ]); $a ++ ) {
if ( ! in_array ( $attributes [ $attrName ][ $a ], $attributesNew [ $attrName ])) {
$return [ 'mod' ][ $attrName ] = $attributesNew [ $attrName ];
break ;
}
2008-03-01 12:25:39 +00:00
}
}
2010-06-16 17:22:47 +00:00
if ( isset ( $attributesNew [ $attrName ])) {
for ( $a = 0 ; $a < sizeof ( $attributesNew [ $attrName ]); $a ++ ) {
if ( ! in_array ( $attributesNew [ $attrName ][ $a ], $attributes [ $attrName ])) {
$return [ 'mod' ][ $attrName ] = $attributesNew [ $attrName ];
break ;
}
2008-03-01 12:25:39 +00:00
}
}
}
}
return $return ;
}
2015-07-11 09:50:00 +00:00
2013-11-03 17:17:47 +00:00
/**
* Returns if the object class " mailrecipient " is managed by this module.
2015-07-11 09:50:00 +00:00
*
2013-11-03 17:17:47 +00:00
* @ return boolean manage mailrecipient object class
*/
private function manageMailrecipient () {
// abort if configuration is not available
if ( ! isset ( $this -> moduleSettings ) || ! is_array ( $this -> moduleSettings )) {
return true ;
}
if ( isset ( $this -> moduleSettings [ 'kolabUser_mailrecipient' ][ 0 ]) && ( $this -> moduleSettings [ 'kolabUser_mailrecipient' ][ 0 ] == 'false' )) {
return false ;
}
return true ;
2015-07-11 09:50:00 +00:00
2013-11-03 17:17:47 +00:00
}
2008-03-01 12:25:39 +00:00
2005-08-01 11:58:07 +00:00
}
?>