2013-11-02 15:06:03 +00:00
< ? php
/*
$Id $
This code is part of LDAP Account Manager ( http :// www . ldap - account - manager . org / )
2014-04-13 16:59:56 +00:00
Copyright ( C ) 2013 - 2014 Roland Gruber
2013-11-02 15:06:03 +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 shared folders .
*
* @ package modules
* @ author Roland Gruber
*/
/**
* Manages Kolab shared folders .
*
* @ package modules
*/
2013-11-03 20:00:12 +00:00
class kolabSharedFolder extends baseModule { // TODO folder type
2013-11-02 15:06:03 +00:00
/** cache for mailHost values */
private $mailHostCache = null ;
2013-11-03 17:17:47 +00:00
/** list of folder types (label => id) */
private $folderTypes = array ();
2013-11-02 15:06:03 +00:00
/**
* Creates a new kolabSharedFolder object .
*
* @ param string $scope account type ( user , group , host )
*/
function __construct ( $scope ) {
// call parent constructor
parent :: __construct ( $scope );
2013-11-03 17:17:47 +00:00
$this -> folderTypes = array (
// TODO reactivate types when stable 3.1 is released
2013-11-03 20:00:12 +00:00
/* _ ( 'Shared address book' ) => 'addressbook' ,
_ ( 'Shared calendar' ) => 'calendar' ,
_ ( 'Shared journal' ) => 'journal' ,
_ ( 'Shared tasks' ) => 'task' , */
_ ( 'Shared mail folder' ) => 'mail' ,
2013-11-03 17:17:47 +00:00
);
2013-11-02 15:06:03 +00:00
}
/**
* Returns meta data that is interpreted by parent class
*
* @ return array array with meta data
*
* @ see baseModule :: get_metaData ()
*/
function get_metaData () {
$return = array ();
// icon
$return [ 'icon' ] = 'kolab.png' ;
// manages host accounts
2013-11-03 17:17:47 +00:00
$return [ " account_types " ] = array ( 'kolabSharedFolderType' );
2013-11-02 15:06:03 +00:00
// alias name
$return [ " alias " ] = _ ( " Kolab shared folder " );
2013-11-03 17:17:47 +00:00
// this is a base module
$return [ " is_base " ] = true ;
// RDN attribute
$return [ " RDN " ] = array ( " cn " => " normal " );
2013-11-02 15:06:03 +00:00
// module dependencies
$return [ 'dependencies' ] = array ( 'depends' => array (), 'conflicts' => array ());
2013-11-03 17:17:47 +00:00
// LDAP filter
$return [ " ldap_filter " ] = array ( 'or' => " (objectClass=kolabSharedFolder) " );
2013-11-02 15:06:03 +00:00
// managed object classes
2013-11-03 17:17:47 +00:00
$return [ 'objectClasses' ] = array ( 'kolabSharedFolder' , 'mailrecipient' );
2013-11-02 15:06:03 +00:00
// managed attributes
2013-11-03 17:17:47 +00:00
$return [ 'attributes' ] = array ( 'cn' , 'kolabAllowSMTPRecipient' , 'kolabAllowSMTPSender' , 'kolabDeleteflag' , 'acl' ,
'alias' , 'kolabDelegate' , 'kolabFolderType' , 'kolabTargetFolder' , 'mailHost' , 'mail' );
// profile options
$profileContainer = new htmlTable ();
$profileContainer -> addElement ( new htmlTableExtendedInputField ( _ ( 'Mail server' ), 'kolab_mailHost' , null , 'mailHost' ), true );
$return [ 'profile_options' ] = $profileContainer ;
// profile checks
$return [ 'profile_checks' ][ 'kolab_mailHost' ] = array (
'type' => 'ext_preg' ,
'regex' => 'DNSname' ,
'error_message' => $this -> messages [ 'mailHost' ][ 0 ]);
// profile mappings
$return [ 'profile_mappings' ] = array (
'kolab_mailHost' => 'mailHost' ,
);
2013-11-02 15:06:03 +00:00
// help Entries
$return [ 'help' ] = array (
2013-11-03 17:17:47 +00:00
'cn' => array (
" Headline " => _ ( " Name " ), 'attr' => 'cn' ,
" Text " => _ ( " Please enter a name for this folder. " )
),
'mail' => array (
" Headline " => _ ( " Email address " ), 'attr' => 'mail' ,
" Text " => _ ( " The folder's email address. " )
),
2013-11-02 15:06:03 +00:00
'kolabAllowSMTPRecipient' => array (
2013-12-01 10:02:20 +00:00
" Headline " => _ ( 'Allowed recipients' ), 'attr' => 'kolabAllowSMTPRecipient' ,
2013-11-02 15:06:03 +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-11-02 15:06:03 +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
'delegate' => array (
" Headline " => _ ( " Delegates " ), 'attr' => 'kolabDelegate' ,
" Text " => _ ( " Delegates are allowed to act on behalf of the shared folder. This property is checked when using the Kolab smtp daemon (Postfix) to send emails. " )
),
'delegateList' => array (
" Headline " => _ ( " Delegates " ), 'attr' => 'kolabDelegate' ,
" Text " => _ ( " This is a comma separated list of delegates. " )
),
'alias' => array (
" Headline " => _ ( " Email alias " ), 'attr' => 'alias' ,
" Text " => _ ( " Email alias for this account. " )
),
'aliasList' => array (
" Headline " => _ ( " Email alias list " ), 'attr' => 'alias' ,
" Text " => _ ( " This is a comma separated list of eMail aliases. " )
),
'mailHost' => array (
" Headline " => _ ( " Mailbox home server " ), 'attr' => 'mailHost' ,
" Text " => _ ( " The name of the server where the mailbox is located. " )
),
2013-11-03 20:00:12 +00:00
'kolabTargetFolder' => array (
" Headline " => _ ( " Target IMAP folder " ), 'attr' => 'kolabTargetFolder' ,
" Text " => _ ( " The folder on the server where the shared folder is located (e.g. user/myfolder@example.com). " )
),
'kolabFolderType' => array (
" Headline " => _ ( " Type " ), 'attr' => 'kolabFolderType' ,
" Text " => _ ( " Specifies the folder type (e.g. shared mail folder). " )
),
2013-11-02 15:06:03 +00:00
'deleteFlag' => array (
" Headline " => _ ( " Mark for deletion " ), 'attr' => 'kolabDeleteflag' ,
" 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). " )
),
);
// upload fields
$return [ 'upload_columns' ] = array (
array (
2013-11-03 17:17:47 +00:00
'name' => 'kolabSharedFolder_cn' ,
'description' => _ ( 'Name' ),
'help' => 'cn' ,
'example' => 'folder' ,
'required' => true
),
array (
'name' => 'kolabSharedFolder_mail' ,
'description' => _ ( 'Email address' ),
'help' => 'mail' ,
'example' => _ ( 'user@company.com' ),
'required' => true
),
array (
'name' => 'kolabSharedFolder_mailHost' ,
'description' => _ ( 'Mailbox home server' ),
'help' => 'mailHost' ,
'example' => 'localhost' ,
2013-11-03 20:00:12 +00:00
),
array (
'name' => 'kolabSharedFolder_kolabTargetFolder' ,
'description' => _ ( 'Target IMAP folder' ),
'help' => 'kolabTargetFolder' ,
'example' => 'user/myfolder@example.com' ,
'required' => true
),
array (
'name' => 'kolabSharedFolder_kolabFolderType' ,
'description' => _ ( 'Type' ),
'help' => 'kolabFolderType' ,
'example' => 'mail' ,
2013-11-03 17:17:47 +00:00
'required' => true
2013-11-02 15:06:03 +00:00
),
array (
'name' => 'kolabSharedFolder_kolabAllowSMTPRecipient' ,
2013-12-01 10:02:20 +00:00
'description' => _ ( 'Allowed recipients' ),
2013-11-02 15:06:03 +00:00
'help' => 'kolabAllowSMTPRecipientList' ,
'example' => '.com; -.net' ,
),
array (
'name' => 'kolabSharedFolder_kolabAllowSMTPSender' ,
'description' => _ ( 'Allowed senders' ),
'help' => 'kolabAllowSMTPSenderList' ,
'example' => '.com; -.net' ,
),
2013-11-03 17:17:47 +00:00
array (
'name' => 'kolabSharedFolder_aliases' ,
'description' => _ ( 'Email aliases' ),
'help' => 'aliasList' ,
'example' => 'user@domain,user2@domain'
),
array (
'name' => 'kolabSharedFolder_delegates' ,
'description' => _ ( 'Delegates' ),
'help' => 'delegateList' ,
'example' => 'user@domain,user2@domain'
),
2013-11-02 15:06:03 +00:00
);
// available PDF fields
$return [ 'PDF_fields' ] = array (
2013-11-03 17:17:47 +00:00
'cn' => _ ( 'Name' ),
2013-12-01 10:02:20 +00:00
'kolabAllowSMTPRecipient' => _ ( 'Allowed recipients' ),
2013-11-02 15:06:03 +00:00
'kolabAllowSMTPSender' => _ ( 'Allowed senders' ),
2013-11-03 17:17:47 +00:00
'aliases' => _ ( 'Email aliases' ),
'delegate' => _ ( 'Delegates' ),
'mailHost' => _ ( 'Mailbox home server' ),
'mail' => _ ( 'Email address' ),
2013-11-03 20:00:12 +00:00
'kolabTargetFolder' => _ ( 'Target IMAP folder' ),
'kolabFolderType' => _ ( 'Type' ),
2013-11-02 15:06:03 +00:00
);
return $return ;
}
/**
* This function fills the $messages variable with output messages from this module .
*/
function load_Messages () {
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:' ) . ' kolabSharedFolder_kolabAllowSMTPRecipient' , _ ( 'Please enter a valid recipient expression.' ));
2013-11-02 15:06:03 +00:00
$this -> messages [ 'kolabAllowSMTPSender' ][ 0 ] = array ( 'ERROR' , _ ( 'Allowed senders' ), _ ( 'Please enter a valid sender expression.' ));
$this -> messages [ 'kolabAllowSMTPSender' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabSharedFolder_kolabAllowSMTPSender' , _ ( 'Please enter a valid sender expression.' ));
2013-11-03 17:17:47 +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:' ) . ' kolabSharedFolder_aliases' , _ ( 'Email alias list has invalid format!' ));
$this -> messages [ 'delegate' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabSharedFolder_delegates' , _ ( 'Unknown delegate address: %s' ));
$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:' ) . ' kolabSharedFolder_mailHost' , _ ( 'Mailbox home server name is invalid!' ));
$this -> messages [ 'mail' ][ 0 ] = array ( 'ERROR' , _ ( 'Email address' ), _ ( 'Please enter a valid email address!' ));
$this -> messages [ 'mail' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' kolabSharedFolder_mail' , _ ( 'Please enter a valid email address!' ));
2013-11-03 20:00:12 +00:00
$this -> messages [ 'cn' ][ 0 ] = array ( 'ERROR' , _ ( 'Name' ), _ ( 'Please enter a name.' ));
$this -> messages [ 'kolabTargetFolder' ][ 0 ] = array ( 'ERROR' , _ ( 'Target IMAP folder' ), _ ( 'Please enter a target folder.' ));
2013-11-02 15:06:03 +00:00
}
/**
* Returns the HTML meta data for the main account page .
*
* @ return htmlElement HTML meta data
*/
function display_html_attributes () {
$container = new htmlTable ();
2013-11-03 17:17:47 +00:00
// check if account is marked for deletion
if ( isset ( $this -> attributes [ 'kolabDeleteflag' ])) {
$container -> addElement ( new htmlOutputText ( _ ( 'This account is marked for deletion.' )));
return $container ;
}
$baseContainer = new htmlTable ();
// name
$this -> addSimpleInputTextField ( $baseContainer , 'cn' , _ ( 'Name' ), true );
// mail
$this -> addSimpleInputTextField ( $baseContainer , 'mail' , _ ( 'Email address' ), true );
// mailbox server
if ( ! isset ( $this -> orig [ 'mailHost' ][ 0 ])) { // value currently not set
2013-11-03 20:00:12 +00:00
$this -> addSimpleInputTextField ( $baseContainer , 'mailHost' , _ ( 'Mailbox home server' ));
2013-11-03 17:17:47 +00:00
}
else { // input is unchangable when set
$baseContainer -> addElement ( new htmlOutputText ( _ ( 'Mailbox home server' )));
$baseContainer -> addElement ( new htmlOutputText ( $this -> attributes [ 'mailHost' ][ 0 ]));
$baseContainer -> addElement ( new htmlHelpLink ( 'mailHost' ), true );
}
2013-11-03 20:00:12 +00:00
// target folder
$this -> addSimpleInputTextField ( $baseContainer , 'kolabTargetFolder' , _ ( 'Target IMAP folder' ), true );
// folder type
$possibleTypes = $this -> folderTypes ;
$selectedTypes = array ( 'mail' );
if ( ! empty ( $this -> attributes [ 'kolabFolderType' ])) {
$selectedTypes = $this -> attributes [ 'kolabFolderType' ];
if ( ! in_array ( $this -> attributes [ 'kolabFolderType' ][ 0 ], $possibleTypes )) {
$possibleTypes [ $this -> attributes [ 'kolabFolderType' ][ 0 ]] = $this -> attributes [ 'kolabFolderType' ][ 0 ];
}
}
$typeSelect = new htmlTableExtendedSelect ( 'kolabFolderType' , $possibleTypes , $selectedTypes , _ ( 'Type' ), 'kolabFolderType' );
$typeSelect -> setHasDescriptiveElements ( true );
$baseContainer -> addElement ( $typeSelect , true );
$baseContainer -> addVerticalSpace ( '10px' );
2013-12-01 10:02:20 +00:00
// allowed recipients
$this -> addMultiValueInputTextField ( $baseContainer , 'kolabAllowSMTPRecipient' , _ ( 'Allowed recipients' ));
2013-11-03 17:17:47 +00:00
// allowed senders
$this -> addMultiValueInputTextField ( $baseContainer , 'kolabAllowSMTPSender' , _ ( 'Allowed senders' ));
$container -> addElement ( $baseContainer , true );
// mail aliases
$container -> addElement ( new htmlSubTitle ( _ ( 'Email aliases' )), true );
2013-12-17 20:24:13 +00:00
$this -> addMultiValueInputTextField ( $container , 'alias' , null );
2013-11-03 17:17:47 +00:00
// delegates
$delegates = searchLDAPByAttribute ( 'mail' , '*' , 'inetOrgPerson' , array ( 'mail' ), array ( 'user' ));
for ( $i = 0 ; $i < sizeof ( $delegates ); $i ++ ) {
$delegates [ $i ] = $delegates [ $i ][ 'mail' ][ 0 ];
}
sort ( $delegates );
$container -> addElement ( new htmlSubTitle ( _ ( 'Delegates' )), true );
$delegatesContainer = new htmlTable ();
$delegatesContainer -> colspan = 3 ;
if ( isset ( $this -> attributes [ 'kolabDelegate' ])) {
for ( $i = 0 ; $i < sizeof ( $this -> attributes [ 'kolabDelegate' ]); $i ++ ) {
$delegatesContainer -> addElement ( new htmlSelect ( 'delegate' . $i , $delegates , array ( $this -> attributes [ 'kolabDelegate' ][ $i ])));
$delegatesContainer -> addElement ( new htmlButton ( 'delDelegate' . $i , 'del.png' , true ));
if ( $i == 0 ) {
$delegatesContainer -> addElement ( new htmlHelpLink ( 'delegate' ));
}
$delegatesContainer -> addNewLine ();
2013-11-02 15:06:03 +00:00
}
}
2013-11-03 17:17:47 +00:00
// input box for new delegate
$delegatesContainer -> addElement ( new htmlSelect ( 'delegate' , $delegates ));
$delegatesContainer -> addElement ( new htmlButton ( 'addDelegate' , 'add.png' , true ));
if ( empty ( $this -> attributes [ 'kolabDelegate' ])) {
$delegatesContainer -> addElement ( new htmlHelpLink ( 'delegate' ));
}
$container -> addElement ( $delegatesContainer , true );
// delete flag
$this -> loadMailHostCache ();
if ( ! $this -> getAccountContainer () -> isNewAccount && ( sizeof ( $this -> mailHostCache ) > 0 )) {
$deleteContainer = new htmlTable ();
$deleteContainer -> addElement ( new htmlSpacer ( null , '20px' ), true );
$deleteContainer -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'deleteFlag' , 'open' , _ ( 'Mark account for deletion' )));
$deleteContainer -> addElement ( new htmlHelpLink ( 'deleteFlag' ));
$container -> addElement ( $deleteContainer );
2013-11-02 15:06:03 +00:00
}
return $container ;
}
/**
* Processes user input of the primary module page .
* It checks if all input values are correct and updates the associated LDAP attributes .
*
* @ return array list of info / error messages
*/
function process_attributes () {
$errors = array ();
2013-11-03 17:17:47 +00:00
// cn
$this -> attributes [ 'cn' ][ 0 ] = $_POST [ 'cn' ];
2013-11-03 20:00:12 +00:00
if ( empty ( $_POST [ 'cn' ])) {
$errors [] = $this -> messages [ 'cn' ][ 0 ];
}
2013-11-03 17:17:47 +00:00
// mail
$this -> attributes [ 'mail' ][ 0 ] = $_POST [ 'mail' ];
if ( empty ( $_POST [ 'mail' ]) || ! get_preg ( $_POST [ 'mail' ], 'email' )) {
$errors [] = $this -> messages [ 'mail' ][ 0 ];
2013-11-02 15:06:03 +00:00
}
2013-11-03 17:17:47 +00:00
// mailbox server
if ( isset ( $_POST [ 'mailHost' ])) {
2013-11-03 20:00:12 +00:00
if (( $_POST [ 'mailHost' ] == " " ) && isset ( $this -> attributes [ 'mailHost' ])) {
unset ( $this -> attributes [ 'mailHost' ]);
2013-11-03 17:17:47 +00:00
}
2013-11-03 20:00:12 +00:00
elseif ( ! empty ( $_POST [ 'mailHost' ])) {
if ( get_preg ( $_POST [ 'mailHost' ], 'DNSname' )) {
$this -> attributes [ 'mailHost' ][ 0 ] = $_POST [ 'mailHost' ];
}
else {
$message = $this -> messages [ 'mailHost' ][ 0 ];
$message [] = $_POST [ 'mailHost' ];
$errors [] = $message ;
}
2013-11-02 15:06:03 +00:00
}
}
2013-11-03 20:00:12 +00:00
// target folder
$this -> attributes [ 'kolabTargetFolder' ][ 0 ] = $_POST [ 'kolabTargetFolder' ];
if ( empty ( $_POST [ 'kolabTargetFolder' ])) {
$errors [] = $this -> messages [ 'kolabTargetFolder' ][ 0 ];
}
// folder type
$this -> attributes [ 'kolabFolderType' ][ 0 ] = $_POST [ 'kolabFolderType' ];
2013-12-01 10:02:20 +00:00
// allowed recipients
2013-11-02 15:06:03 +00:00
$this -> processMultiValueInputTextField ( 'kolabAllowSMTPRecipient' , $errors , 'kolabEmailPrefix' );
// allowed senders
$this -> processMultiValueInputTextField ( 'kolabAllowSMTPSender' , $errors , 'kolabEmailPrefix' );
2013-11-03 17:17:47 +00:00
// mail aliases
$this -> processMultiValueInputTextField ( 'alias' , $errors , 'email' );
// 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 ];
$i ++ ;
}
// check new delegate
if ( isset ( $_POST [ 'addDelegate' ]) && ( $_POST [ 'delegate' ] != " " )) {
$this -> attributes [ 'kolabDelegate' ][] = $_POST [ 'delegate' ];
}
$this -> attributes [ 'kolabDelegate' ] = array_unique ( $this -> attributes [ 'kolabDelegate' ]);
2013-11-02 15:06:03 +00:00
return $errors ;
}
/**
* This function will create the meta HTML code to show a page to mark an account for deletion .
*
* @ return htmlElement HTML meta data
*/
function display_html_deleteFlag () {
$return = new htmlTable ();
$message = new htmlOutputText ( _ ( 'Do you really want to mark this account for deletion?' ));
$return -> addElement ( $message , true );
$return -> addElement ( new htmlSpacer ( null , '10px' ), true );
$serverTable = new htmlTable ();
$serverTable -> addElement ( new htmlTableExtendedSelect ( 'deletionServer' , $this -> mailHostCache , array (), _ ( 'Server' ), 'deleteFlag' ));
$return -> addElement ( $serverTable , true );
$return -> addElement ( new htmlSpacer ( null , '10px' ), true );
$buttonGroup = new htmlGroup ();
$buttonGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'confirm' , _ ( 'Mark account for deletion' )));
$buttonGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'cancel' , _ ( 'Cancel' )));
$return -> addElement ( $buttonGroup , true );
return $return ;
}
/**
* Write variables into object and do some regex checks
*/
function process_deleteFlag () {
if ( isset ( $_POST [ 'form_subpage_kolabSharedFolder_attributes_confirm' ])) {
// set delete flag
$this -> attributes [ 'kolabDeleteflag' ][ 0 ] = $_POST [ 'deletionServer' ];
}
}
/**
* 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 )
* @ param array $partialAccounts list of hash arrays ( name => value ) which are later added to LDAP
* @ param array $selectedModules list of selected account modules
* @ return array list of error messages if any
*/
function build_uploadAccounts ( $rawAccounts , $ids , & $partialAccounts , $selectedModules ) {
$messages = array ();
2013-11-03 17:17:47 +00:00
$delegates = searchLDAPByAttribute ( null , null , 'inetOrgPerson' , array ( 'mail' ), array ( 'user' ));
for ( $d = 0 ; $d < sizeof ( $delegates ); $d ++ ) {
if ( isset ( $delegates [ $d ][ 'mail' ][ 0 ])) {
$delegates [ $d ] = $delegates [ $d ][ 'mail' ][ 0 ];
}
}
2013-11-02 15:06:03 +00:00
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
2013-11-03 17:17:47 +00:00
// add object classes
if ( ! in_array ( 'kolabSharedFolder' , $partialAccounts [ $i ][ 'objectClass' ])) {
$partialAccounts [ $i ][ 'objectClass' ][] = 'kolabSharedFolder' ;
}
if ( ! in_array ( 'mailrecipient' , $partialAccounts [ $i ][ 'objectClass' ])) {
$partialAccounts [ $i ][ 'objectClass' ][] = 'mailrecipient' ;
2013-11-02 15:06:03 +00:00
}
2013-11-03 17:17:47 +00:00
// cn
$partialAccounts [ $i ][ 'cn' ] = $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_cn' ]];
// mail
2014-04-13 16:59:56 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'kolabSharedFolder_mail' , 'mail' ,
'email' , $this -> messages [ 'mail' ][ 1 ], $messages );
2013-11-03 17:17:47 +00:00
// mailbox server
2014-04-13 16:59:56 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'kolabSharedFolder_mailHost' , 'mailHost' ,
'DNSname' , $this -> messages [ 'mailHost' ][ 1 ], $messages );
2013-11-03 20:00:12 +00:00
// target folder
$partialAccounts [ $i ][ 'kolabTargetFolder' ] = $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_kolabTargetFolder' ]];
// folder type
$partialAccounts [ $i ][ 'kolabFolderType' ] = $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_kolabFolderType' ]];
2013-11-02 15:06:03 +00:00
// allowed recipients
if ( ! empty ( $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_kolabAllowSMTPRecipient' ]])) {
$mails = preg_split ( '/;[ ]*/' , $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_kolabAllowSMTPRecipient' ]]);
for ( $m = 0 ; $m < sizeof ( $mails ); $m ++ ) {
if ( get_preg ( $mails [ $m ], 'kolabEmailPrefix' )) {
$partialAccounts [ $i ][ 'kolabAllowSMTPRecipient' ][] = $mails [ $m ];
}
else {
$errMsg = $this -> messages [ 'kolabAllowSMTPRecipient' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$messages [] = $errMsg ;
break ;
}
}
}
// allowed senders
if ( ! empty ( $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_kolabAllowSMTPSender' ]])) {
$mails = preg_split ( '/;[ ]*/' , $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_kolabAllowSMTPSender' ]]);
for ( $m = 0 ; $m < sizeof ( $mails ); $m ++ ) {
if ( get_preg ( $mails [ $m ], 'kolabEmailPrefix' )) {
$partialAccounts [ $i ][ 'kolabAllowSMTPSender' ][] = $mails [ $m ];
}
else {
$errMsg = $this -> messages [ 'kolabAllowSMTPSender' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$messages [] = $errMsg ;
break ;
}
}
}
2013-11-03 17:17:47 +00:00
// add mail aliases
if ( $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_aliases' ]] != " " ) {
$aliases = explode ( ',' , $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_aliases' ]]);
// check format
for ( $a = 0 ; $a < sizeof ( $aliases ); $a ++ ) {
if ( get_preg ( $aliases [ $a ], 'email' )) {
$partialAccounts [ $i ][ 'alias' ][] = $aliases [ $a ];
}
// invalid format
else {
$errMsg = $this -> messages [ 'alias' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$messages [] = $errMsg ;
}
}
}
// add delegates
if ( $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_delegates' ]] != " " ) {
$newDelegates = explode ( ',' , $rawAccounts [ $i ][ $ids [ 'kolabSharedFolder_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 ];
array_push ( $errMsg , array ( $i , $newDelegates [ $d ]));
$messages [] = $errMsg ;
}
}
}
2013-11-02 15:06:03 +00:00
}
return $messages ;
}
/**
* Returns a list of PDF entries
*/
function get_pdfEntries () {
$return = array ();
2013-11-03 17:17:47 +00:00
$this -> addSimplePDFField ( $return , 'cn' , _ ( 'Name' ));
$this -> addSimplePDFField ( $return , 'mail' , _ ( 'Email address' ));
$this -> addSimplePDFField ( $return , 'mailHost' , _ ( 'Mailbox home server' ));
2013-11-03 20:00:12 +00:00
$this -> addSimplePDFField ( $return , 'kolabTargetFolder' , _ ( 'Target IMAP folder' ));
2013-12-01 10:02:20 +00:00
$this -> addSimplePDFField ( $return , 'kolabAllowSMTPRecipient' , _ ( 'Allowed recipients' ));
2013-11-02 15:06:03 +00:00
$this -> addSimplePDFField ( $return , 'kolabAllowSMTPSender' , _ ( 'Allowed senders' ));
2013-11-03 17:17:47 +00:00
$this -> addSimplePDFField ( $return , 'aliases' , _ ( 'Email aliases' ), 'alias' );
$this -> addSimplePDFField ( $return , 'delegate' , _ ( 'Delegates' ), 'kolabDelegate' );
2013-11-03 20:00:12 +00:00
if ( ! empty ( $this -> attributes [ 'kolabFolderType' ])) {
$type = $this -> attributes [ 'kolabFolderType' ][ 0 ];
$typeList = array_flip ( $this -> folderTypes );
if ( isset ( $typeList [ $type ])) {
$type = $typeList [ $type ];
}
$return [ get_class ( $this ) . '_kolabFolderType' ] = array ( '<block><key>' . _ ( 'Type' ) . '</key><value>' . $type . '</value></block>' );
}
2013-11-02 15:06:03 +00:00
return $return ;
}
/**
* Loads the list of mail hosts into the cache .
*/
private function loadMailHostCache () {
if ( $this -> mailHostCache != null ) {
return ;
}
$results = searchLDAPByFilter ( '(mailHost=*)' , array ( 'mailHost' ), array ( 'user' ));
$this -> mailHostCache = array ();
foreach ( $results as $result ) {
if ( isset ( $result [ 'mailhost' ][ 0 ]) && ! in_array_ignore_case ( $result [ 'mailhost' ][ 0 ], $this -> mailHostCache )) {
$this -> mailHostCache [] = $result [ 'mailhost' ][ 0 ];
}
}
}
}
?>