Kolab update

This commit is contained in:
Roland Gruber 2013-11-03 17:17:47 +00:00
parent 599db388f0
commit 819384f1cb
8 changed files with 496 additions and 161 deletions

View File

@ -692,6 +692,14 @@ Have fun!
<section id="a_versUpgrade"> <section id="a_versUpgrade">
<title>Version specific upgrade instructions</title> <title>Version specific upgrade instructions</title>
<section>
<title>4.3 -&gt; 4.4</title>
<para>Kolab: User accounts get the object class "mailrecipient" by
default. You can change this behaviour in the module settings
section of your LAM server profile.</para>
</section>
<section> <section>
<title>4.2.1 -&gt; 4.3</title> <title>4.2.1 -&gt; 4.3</title>
@ -2522,6 +2530,20 @@ Have fun!
</mediaobject> </mediaobject>
</screenshot> </screenshot>
<para>Attention: LAM will add the object class "mailrecipient" by
default. This object class is available on 389 directory server but
may not be present on e.g. OpenLDAP. Please deactivate the following
setting (LAM server profile, module settings) if you do not use this
object class.</para>
<screenshot>
<mediaobject>
<imageobject>
<imagedata fileref="images/mod_kolab5.png" />
</imageobject>
</mediaobject>
</screenshot>
<para>Please enter an email address at the Personal page and set a <para>Please enter an email address at the Personal page and set a
Unix password first. Both are required that Kolab accepts the Unix password first. Both are required that Kolab accepts the
accounts. The email address ("Personal" page) must match your Kolab accounts. The email address ("Personal" page) must match your Kolab

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

View File

@ -469,42 +469,6 @@ class kolabGroup extends baseModule {
} }
} }
/**
* Controls if the module button the account page is visible and activated.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* <b>Possible return values:</b>
* <ul>
* <li><b>enabled:</b> button is visible and active</li>
* <li><b>disabled:</b> button is visible and deactivated (greyed)</li>
* <li><b>hidden:</b> no button will be shown</li>
* </ul>
*
* @return string status ("enabled", "disabled", "hidden")
*/
public function getButtonStatus() {
$module = $this->getAccountContainer()->getAccountModule('kolabSharedFolder');
if ($module != null) {
if ($module->extensionIsEnabled()) {
return 'disabled';
}
}
return "enabled";
}
/**
* Returns if the extension is enabled for this LDAP entry.
*
* @return boolean enabled (= object class added to entry)
*/
public function extensionIsEnabled() {
if (isset($this->attributes['objectClass']) && in_array('kolabGroupOfUniqueNames', $this->attributes['objectClass'])) {
return true;
}
return false;
}
} }

View File

@ -32,11 +32,14 @@ $Id$
* *
* @package modules * @package modules
*/ */
class kolabSharedFolder extends baseModule { class kolabSharedFolder extends baseModule { // TODO folder type + kolabTargetFolder
/** cache for mailHost values */ /** cache for mailHost values */
private $mailHostCache = null; private $mailHostCache = null;
/** list of folder types (label => id) */
private $folderTypes = array();
/** /**
* Creates a new kolabSharedFolder object. * Creates a new kolabSharedFolder object.
* *
@ -45,7 +48,14 @@ class kolabSharedFolder extends baseModule {
function __construct($scope) { function __construct($scope) {
// call parent constructor // call parent constructor
parent::__construct($scope); parent::__construct($scope);
$this->autoAddObjectClasses = false; $this->folderTypes = array(
// TODO reactivate types when stable 3.1 is released
/*_('Shared Address Book') => 'addressbook',
_('Shared Calendar') => 'calendar',
_('Shared Journal') => 'journal',
_('Shared Tasks') => 'task',*/
_('Shared Mail Folder') => 'mail',
);
} }
/** /**
@ -60,18 +70,45 @@ class kolabSharedFolder extends baseModule {
// icon // icon
$return['icon'] = 'kolab.png'; $return['icon'] = 'kolab.png';
// manages host accounts // manages host accounts
$return["account_types"] = array('group'); $return["account_types"] = array('kolabSharedFolderType');
// alias name // alias name
$return["alias"] = _("Kolab shared folder"); $return["alias"] = _("Kolab shared folder");
// this is a base module
$return["is_base"] = true;
// RDN attribute
$return["RDN"] = array("cn" => "normal");
// module dependencies // module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array()); $return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=kolabSharedFolder)");
// managed object classes // managed object classes
$return['objectClasses'] = array('kolabSharedFolder'); $return['objectClasses'] = array('kolabSharedFolder', 'mailrecipient');
// managed attributes // managed attributes
$return['attributes'] = array('kolabAllowSMTPRecipient', 'kolabAllowSMTPSender', 'kolabDeleteflag', 'acl', $return['attributes'] = array('cn', 'kolabAllowSMTPRecipient', 'kolabAllowSMTPSender', 'kolabDeleteflag', 'acl',
'alias', 'kolabDelegate', 'kolabFolderType', 'kolabTargetFolder', 'mailHost'); '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',
);
// help Entries // help Entries
$return['help'] = array( $return['help'] = array(
'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.")
),
'kolabAllowSMTPRecipient' => array ( 'kolabAllowSMTPRecipient' => array (
"Headline" => _('Allowed recepients'), 'attr' => 'kolabAllowSMTPRecipient', "Headline" => _('Allowed recepients'), 'attr' => 'kolabAllowSMTPRecipient',
"Text" => _('Describes the allowed or disallowed SMTP recipient addresses for mail sent by this account (e.g. "domain.tld" or "-user@domain.tld").') "Text" => _('Describes the allowed or disallowed SMTP recipient addresses for mail sent by this account (e.g. "domain.tld" or "-user@domain.tld").')
@ -90,24 +127,53 @@ class kolabSharedFolder extends baseModule {
"Text" => _('Describes the allowed or disallowed SMTP addresses sending mail to this account (e.g. "domain.tld" or "-user@domain.tld").') "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.") . ' ' . _("Multiple values are separated by semicolon.")
), ),
'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.")
),
'deleteFlag' => array( 'deleteFlag' => array(
"Headline" => _("Mark for deletion"), 'attr' => 'kolabDeleteflag', "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).") "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).")
), ),
'addExtension' => array(
"Headline" => _("Add Kolab extension"),
"Text" => _("Adds this Kolab extension.")
),
); );
// upload fields // upload fields
$return['upload_columns'] = array( $return['upload_columns'] = array(
array( array(
'name' => 'kolabSharedFolder_addExtension', 'name' => 'kolabSharedFolder_cn',
'description' => _('Add Kolab extension'), 'description' => _('Name'),
'help' => 'addExtension', 'help' => 'cn',
'example' => 'false', 'example' => 'folder',
'default' => 'false', 'required' => true
'values' => 'true, false' ),
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',
'required' => true
), ),
array( array(
'name' => 'kolabSharedFolder_kolabAllowSMTPRecipient', 'name' => 'kolabSharedFolder_kolabAllowSMTPRecipient',
@ -121,11 +187,28 @@ class kolabSharedFolder extends baseModule {
'help' => 'kolabAllowSMTPSenderList', 'help' => 'kolabAllowSMTPSenderList',
'example' => '.com; -.net', 'example' => '.com; -.net',
), ),
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'
),
); );
// available PDF fields // available PDF fields
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'cn' => _('Name'),
'kolabAllowSMTPRecipient' => _('Allowed recepients'), 'kolabAllowSMTPRecipient' => _('Allowed recepients'),
'kolabAllowSMTPSender' => _('Allowed senders'), 'kolabAllowSMTPSender' => _('Allowed senders'),
'aliases' => _('Email aliases'),
'delegate' => _('Delegates'),
'mailHost' => _('Mailbox home server'),
'mail' => _('Email address'),
); );
return $return; return $return;
} }
@ -139,6 +222,14 @@ class kolabSharedFolder extends baseModule {
$this->messages['kolabAllowSMTPSender'][0] = array('ERROR', _('Allowed senders'), _('Please enter a valid sender expression.')); $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.')); $this->messages['kolabAllowSMTPSender'][1] = array('ERROR', _('Account %s:') . ' kolabSharedFolder_kolabAllowSMTPSender', _('Please enter a valid sender expression.'));
$this->messages['extension'][1] = array('ERROR', _('Account %s:') . ' kolabSharedFolder_addExtension', _('You cannot add the Kolab group and shared folder extension at the same time.')); $this->messages['extension'][1] = array('ERROR', _('Account %s:') . ' kolabSharedFolder_addExtension', _('You cannot add the Kolab group and shared folder extension at the same time.'));
$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['mailHost'][2] = array('ERROR', _('Mailbox home server name is empty!'));
$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!'));
} }
/** /**
@ -148,29 +239,67 @@ class kolabSharedFolder extends baseModule {
*/ */
function display_html_attributes() { function display_html_attributes() {
$container = new htmlTable(); $container = new htmlTable();
if (isset($this->attributes['objectClass']) && in_array('kolabSharedFolder', $this->attributes['objectClass'])) { // check if account is marked for deletion
// check if account is marked for deletion if (isset($this->attributes['kolabDeleteflag'])) {
if (isset($this->attributes['kolabDeleteflag'])) { $container->addElement(new htmlOutputText(_('This account is marked for deletion.')));
$container->addElement(new htmlOutputText(_('This account is marked for deletion.'))); return $container;
return $container; }
} $baseContainer = new htmlTable();
// allowed recepients // name
$this->addMultiValueInputTextField($container, 'kolabAllowSMTPRecipient', _('Allowed recepients')); $this->addSimpleInputTextField($baseContainer, 'cn', _('Name'), true);
// allowed senders // mail
$this->addMultiValueInputTextField($container, 'kolabAllowSMTPSender', _('Allowed senders')); $this->addSimpleInputTextField($baseContainer, 'mail', _('Email address'), true);
// delete flag // mailbox server
$this->loadMailHostCache(); if (!isset($this->orig['mailHost'][0])) { // value currently not set
if (!$this->getAccountContainer()->isNewAccount && (sizeof($this->mailHostCache) > 0)) { $this->addSimpleInputTextField($baseContainer, 'mailHost', _('Mailbox home server'), true);
$deleteContainer = new htmlTable(); }
$deleteContainer->addElement(new htmlSpacer(null, '20px'), true); else { // input is unchangable when set
$deleteContainer->addElement(new htmlAccountPageButton(get_class($this), 'deleteFlag', 'open', _('Mark account for deletion'))); $baseContainer->addElement(new htmlOutputText(_('Mailbox home server')));
$deleteContainer->addElement(new htmlHelpLink('deleteFlag')); $baseContainer->addElement(new htmlOutputText($this->attributes['mailHost'][0]));
$container->addElement($deleteContainer); $baseContainer->addElement(new htmlHelpLink('mailHost'), true);
}
// allowed recepients
$this->addMultiValueInputTextField($baseContainer, 'kolabAllowSMTPRecipient', _('Allowed recepients'));
// allowed senders
$this->addMultiValueInputTextField($baseContainer, 'kolabAllowSMTPSender', _('Allowed senders'));
$container->addElement($baseContainer, true);
// mail aliases
$container->addElement(new htmlSubTitle(_('Email aliases')), true);
$this->addMultiValueInputTextField($container, 'alias');
// 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();
} }
} }
else { // input box for new delegate
// add button $delegatesContainer->addElement(new htmlSelect('delegate', $delegates));
$container->addElement(new htmlButton('addObjectClass', _('Add Kolab extension'))); $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);
} }
return $container; return $container;
} }
@ -183,28 +312,49 @@ class kolabSharedFolder extends baseModule {
*/ */
function process_attributes() { function process_attributes() {
$errors = array(); $errors = array();
if (isset($_POST['addObjectClass'])) { // cn
$this->attributes['objectClass'][] = 'kolabSharedFolder'; $this->attributes['cn'][0] = $_POST['cn'];
return $errors; // mail
$this->attributes['mail'][0] = $_POST['mail'];
if (empty($_POST['mail']) || !get_preg($_POST['mail'], 'email')) {
$errors[] = $this->messages['mail'][0];
} }
if (isset($_POST['remObjectClass'])) { // mailbox server
$this->attributes['objectClass'] = array_delete(array('kolabSharedFolder'), $this->attributes['objectClass']); if (isset($_POST['mailHost'])) {
$attrs = $this->meta['attributes']; if ($_POST['mailHost'] == "") {
foreach ($attrs as $name) { $errors[] = $this->messages['mailHost'][2];
if (isset($this->attributes[$name])) { }
unset($this->attributes[$name]); elseif (get_preg($_POST['mailHost'], 'DNSname')) {
} $this->attributes['mailHost'][0] = $_POST['mailHost'];
}
else {
$message = $this->messages['mailHost'][0];
$message[] = $_POST['mailHost'];
$errors[] = $message;
} }
return $errors;
}
// skip processing if object class is not set
if (!isset($this->attributes['objectClass']) || !in_array('kolabSharedFolder', $this->attributes['objectClass'])) {
return $errors;
} }
// allowed recepients // allowed recepients
$this->processMultiValueInputTextField('kolabAllowSMTPRecipient', $errors, 'kolabEmailPrefix'); $this->processMultiValueInputTextField('kolabAllowSMTPRecipient', $errors, 'kolabEmailPrefix');
// allowed senders // allowed senders
$this->processMultiValueInputTextField('kolabAllowSMTPSender', $errors, 'kolabEmailPrefix'); $this->processMultiValueInputTextField('kolabAllowSMTPSender', $errors, 'kolabEmailPrefix');
// 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']);
return $errors; return $errors;
} }
@ -239,26 +389,6 @@ class kolabSharedFolder extends baseModule {
} }
} }
/**
* 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
* <br>"info" are values with informational value (e.g. to be used later by pre/postModify actions)
*/
function save_attributes() {
if (!in_array('kolabSharedFolder', $this->attributes['objectClass']) && !in_array('kolabSharedFolder', $this->orig['objectClass'])) {
// skip saving if the extension was not added/modified
return array();
}
return parent::save_attributes();
}
/** /**
* In this function the LDAP account is built up. * In this function the LDAP account is built up.
* *
@ -270,23 +400,42 @@ class kolabSharedFolder extends baseModule {
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
$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];
}
}
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// check if extension should be added
if (isset($rawAccounts[$i][$ids['kolabSharedFolder_addExtension']]) && ($rawAccounts[$i][$ids['kolabSharedFolder_addExtension']] != 'true')) {
continue;
}
// check if both group and shared folder enxtension should be added
if (isset($rawAccounts[$i][$ids['kolabSharedFolder_addExtension']]) && ($rawAccounts[$i][$ids['kolabSharedFolder_addExtension']] == 'true')
&& isset($rawAccounts[$i][$ids['kolabGroup_addExtension']]) && ($rawAccounts[$i][$ids['kolabGroup_addExtension']] == 'true')) {
$errMsg = $this->messages['extension'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
continue;
}
// add object classes // add object classes
if (!in_array('kolabSharedFolder', $partialAccounts[$i]['objectClass'])) { if (!in_array('kolabSharedFolder', $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = 'kolabSharedFolder'; $partialAccounts[$i]['objectClass'][] = 'kolabSharedFolder';
} }
if (!in_array('mailrecipient', $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = 'mailrecipient';
}
// cn
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['kolabSharedFolder_cn']];
// mail
if (!get_preg($rawAccounts[$i][$ids['kolabSharedFolder_mail']], 'email')) {
$errMsg = $this->messages['mail'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
else {
$partialAccounts[$i]['mail'] = $rawAccounts[$i][$ids['kolabSharedFolder_mail']];
}
// mailbox server
if ($rawAccounts[$i][$ids['kolabSharedFolder_mailHost']] != "") {
if (get_preg($rawAccounts[$i][$ids['kolabSharedFolder_mailHost']], 'DNSname')) {
$partialAccounts[$i]['mailHost'] = $rawAccounts[$i][$ids['kolabSharedFolder_mailHost']];
}
else {
$errMsg = $this->messages['mailHost'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// allowed recipients // allowed recipients
if (!empty($rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPRecipient']])) { if (!empty($rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPRecipient']])) {
$mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPRecipient']]); $mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPRecipient']]);
@ -317,6 +466,38 @@ class kolabSharedFolder extends baseModule {
} }
} }
} }
// 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;
}
}
}
} }
return $messages; return $messages;
} }
@ -326,8 +507,13 @@ class kolabSharedFolder extends baseModule {
*/ */
function get_pdfEntries() { function get_pdfEntries() {
$return = array(); $return = array();
$this->addSimplePDFField($return, 'cn', _('Name'));
$this->addSimplePDFField($return, 'mail', _('Email address'));
$this->addSimplePDFField($return, 'mailHost', _('Mailbox home server'));
$this->addSimplePDFField($return, 'kolabAllowSMTPRecipient', _('Allowed recepients')); $this->addSimplePDFField($return, 'kolabAllowSMTPRecipient', _('Allowed recepients'));
$this->addSimplePDFField($return, 'kolabAllowSMTPSender', _('Allowed senders')); $this->addSimplePDFField($return, 'kolabAllowSMTPSender', _('Allowed senders'));
$this->addSimplePDFField($return, 'aliases', _('Email aliases'), 'alias');
$this->addSimplePDFField($return, 'delegate', _('Delegates'), 'kolabDelegate');
return $return; return $return;
} }
@ -347,42 +533,6 @@ class kolabSharedFolder extends baseModule {
} }
} }
/**
* Controls if the module button the account page is visible and activated.
*
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br>
* <b>Possible return values:</b>
* <ul>
* <li><b>enabled:</b> button is visible and active</li>
* <li><b>disabled:</b> button is visible and deactivated (greyed)</li>
* <li><b>hidden:</b> no button will be shown</li>
* </ul>
*
* @return string status ("enabled", "disabled", "hidden")
*/
public function getButtonStatus() {
$module = $this->getAccountContainer()->getAccountModule('kolabGroup');
if ($module != null) {
if ($module->extensionIsEnabled()) {
return 'disabled';
}
}
return "enabled";
}
/**
* Returns if the extension is enabled for this LDAP entry.
*
* @return boolean enabled (= object class added to entry)
*/
public function extensionIsEnabled() {
if (isset($this->attributes['objectClass']) && in_array('kolabSharedFolder', $this->attributes['objectClass'])) {
return true;
}
return false;
}
} }

View File

@ -77,9 +77,15 @@ class kolabUser extends baseModule {
$return["ldap_filter"] = array('or' => "(objectClass=kolabInetOrgPerson)"); $return["ldap_filter"] = array('or' => "(objectClass=kolabInetOrgPerson)");
// managed object classes // managed object classes
$return['objectClasses'] = array('kolabInetOrgPerson'); $return['objectClasses'] = array('kolabInetOrgPerson');
if ($this->manageMailrecipient()) {
$return['objectClasses'][] = 'mailrecipient';
}
// managed attributes // managed attributes
$return['attributes'] = array('alias', 'mailHost', 'kolabDelegate', 'kolabInvitationPolicy', 'kolabDeleteflag', $return['attributes'] = array('alias', 'mailHost', 'kolabDelegate', 'kolabInvitationPolicy', 'kolabDeleteflag',
'kolabAllowSMTPRecipient', 'kolabAllowSMTPSender'); 'kolabAllowSMTPRecipient', 'kolabAllowSMTPSender');
if ($this->manageMailrecipient()) {
$return['attributes'][] = 'mailQuota';
}
// profile options // profile options
$profileContainer = new htmlTable(); $profileContainer = new htmlTable();
$profileContainer->addElement(new htmlTableExtendedInputField(_('Mail server'), 'kolab_mailHost', null, 'mailHost'), true); $profileContainer->addElement(new htmlTableExtendedInputField(_('Mail server'), 'kolab_mailHost', null, 'mailHost'), true);
@ -93,6 +99,10 @@ class kolabUser extends baseModule {
$return['profile_mappings'] = array( $return['profile_mappings'] = array(
'kolab_mailHost' => 'mailHost', 'kolab_mailHost' => 'mailHost',
); );
// config options
$configContainer = new htmlTable();
$configContainer->addElement(new htmlTableExtendedInputCheckbox('kolabUser_mailrecipient', true, _('Manage object class "mailrecipient"'), 'mailrecipient'), true);
$return['config_options']['all'] = $configContainer;
// self service field settings // self service field settings
$return['selfServiceFieldSettings'] = array( $return['selfServiceFieldSettings'] = array(
'kolabDelegate' => _('Delegates'), 'kolabDelegate' => _('Delegates'),
@ -148,10 +158,15 @@ class kolabUser extends baseModule {
"Text" => _('Describes the allowed or disallowed SMTP addresses sending mail to this account (e.g. "domain.tld" or "-user@domain.tld").') "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.") . ' ' . _("Multiple values are separated by semicolon.")
), ),
'mailrecipient' => array(
"Headline" => _('Manage object class "mailrecipient"'),
"Text" => _('Adds the object class "mailrecipient" to all user accounts.')
),
'deleteFlag' => array( 'deleteFlag' => array(
"Headline" => _("Mark for deletion"), 'attr' => 'kolabDeleteflag', "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).") "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 // upload fields
$return['upload_columns'] = array( $return['upload_columns'] = array(
array( array(
@ -215,7 +230,7 @@ class kolabUser extends baseModule {
$this->messages['mailHost'][0] = array('ERROR', _('Mailbox home server name is invalid!')); // third array value is set dynamically $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'][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!')); $this->messages['mailHost'][2] = array('ERROR', _('Mailbox home server name is empty!'));
$this->messages['delegate'][0] = array('ERROR', _('Account %s:') . ' kolabUser_delegate', _('Unknown delegate address: %s')); $this->messages['delegate'][0] = array('ERROR', _('Account %s:') . ' kolabUser_delegates', _('Unknown delegate address: %s'));
$this->messages['kolabAllowSMTPRecipient'][0] = array('ERROR', _('Allowed recepients'), _('Please enter a valid recepient expression.')); $this->messages['kolabAllowSMTPRecipient'][0] = array('ERROR', _('Allowed recepients'), _('Please enter a valid recepient expression.'));
$this->messages['kolabAllowSMTPRecipient'][1] = array('ERROR', _('Account %s:') . ' kolabUser_kolabAllowSMTPRecipient', _('Please enter a valid recepient expression.')); $this->messages['kolabAllowSMTPRecipient'][1] = array('ERROR', _('Account %s:') . ' kolabUser_kolabAllowSMTPRecipient', _('Please enter a valid recepient expression.'));
$this->messages['kolabAllowSMTPSender'][0] = array('ERROR', _('Allowed senders'), _('Please enter a valid sender expression.')); $this->messages['kolabAllowSMTPSender'][0] = array('ERROR', _('Allowed senders'), _('Please enter a valid sender expression.'));
@ -317,13 +332,18 @@ class kolabUser extends baseModule {
for ($i = 0; $i < sizeof($this->attributes['kolabDelegate']); $i++) { for ($i = 0; $i < sizeof($this->attributes['kolabDelegate']); $i++) {
$delegatesContainer->addElement(new htmlSelect('delegate' . $i, $delegates, array($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)); $delegatesContainer->addElement(new htmlButton('delDelegate' . $i, 'del.png', true));
$delegatesContainer->addElement(new htmlHelpLink('delegate'), true); if ($i == 0) {
$delegatesContainer->addElement(new htmlHelpLink('delegate'));
}
$delegatesContainer->addNewLine();
} }
} }
// input box for new delegate // input box for new delegate
$delegatesContainer->addElement(new htmlSelect('delegate', $delegates)); $delegatesContainer->addElement(new htmlSelect('delegate', $delegates));
$delegatesContainer->addElement(new htmlButton('addDelegate', 'add.png', true)); $delegatesContainer->addElement(new htmlButton('addDelegate', 'add.png', true));
$delegatesContainer->addElement(new htmlHelpLink('delegate'), true); if (empty($this->attributes['kolabDelegate'])) {
$delegatesContainer->addElement(new htmlHelpLink('delegate'));
}
$return->addElement($delegatesContainer, true); $return->addElement($delegatesContainer, true);
$return->addElement(new htmlSubTitle(_('Options')), true); $return->addElement(new htmlSubTitle(_('Options')), true);
// allowed recepients // allowed recepients
@ -355,6 +375,9 @@ class kolabUser extends baseModule {
$errors = array(); $errors = array();
if (isset($_POST['addObjectClass'])) { if (isset($_POST['addObjectClass'])) {
$this->attributes['objectClass'][] = 'kolabInetOrgPerson'; $this->attributes['objectClass'][] = 'kolabInetOrgPerson';
if ($this->manageMailrecipient()) {
$this->attributes['objectClass'][] = 'mailrecipient';
}
} }
else { else {
if (isset($_POST['form_subpage_kolabUser_deleteUser_open'])) return array(); if (isset($_POST['form_subpage_kolabUser_deleteUser_open'])) return array();
@ -525,7 +548,12 @@ class kolabUser extends baseModule {
} }
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class
if (!in_array("kolabInetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "kolabInetOrgPerson"; if (!in_array("kolabInetOrgPerson", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "kolabInetOrgPerson";
}
if ($this->manageMailrecipient() && !in_array("mailrecipient", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "mailrecipient";
}
// mailbox server // mailbox server
if ($rawAccounts[$i][$ids['kolabUser_mailHost']] != "") { if ($rawAccounts[$i][$ids['kolabUser_mailHost']] != "") {
if (get_preg($rawAccounts[$i][$ids['kolabUser_mailHost']], 'DNSname')) { if (get_preg($rawAccounts[$i][$ids['kolabUser_mailHost']], 'DNSname')) {
@ -914,6 +942,23 @@ class kolabUser extends baseModule {
} }
return $return; return $return;
} }
/**
* Returns if the object class "mailrecipient" is managed by this module.
*
* @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;
}
} }

View File

@ -0,0 +1,150 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2013 Roland Gruber
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
*/
/**
* The account type for Kolab shared folders.
*
* @package types
* @author Roland Gruber
*/
/**
* The account type for Kolab shared folders.
*
* @package types
*/
class kolabSharedFolderType extends baseType {
/**
* Constructs a new shared folder object.
*/
public function __construct() {
parent::__construct();
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another shared folder');
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to shared folder list');
}
/**
* Returns the alias name of this account type.
*
* @return string alias name
*/
function getAlias() {
return _("Kolab shared folders");
}
/**
* Returns the description of this account type.
*
* @return string description
*/
function getDescription() {
return _("Kolab shared folders (e.g. mail folders)");
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "kolabSharedFolderTypeList";
}
/**
* Returns the default attribute list for this account type.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "#cn;#kolabDelegate;#alias";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array (
"kolabDelegate" => _('Delegates'),
'alias' => _('Email aliases'),
);
}
/**
* Returns the the title text for the title bar on the new/edit page.
*
* @param accountContainer $container account container
* @return String title text
*/
public function getTitleBarTitle($container) {
// get attributes
$attributes = array();
if ($container->getAccountModule('kolabSharedFolder') != null) {
$attributes = $container->getAccountModule('kolabSharedFolder')->getAttributes();
}
// check if cn is set
if (isset($attributes['cn'][0])) {
return htmlspecialchars($attributes['cn'][0]);
}
// show new label
if ($container->isNewAccount) {
return _("New shared folder");
}
// fall back to default
return parent::getTitleBarTitle($container);
}
}
/**
* Generates the list view.
*
* @package lists
* @author Roland Gruber
*
*/
class kolabSharedFolderTypeList extends lamList {
/**
* Constructor
*
* @param string $type account type
* @return lamList list object
*/
function __construct($type) {
parent::__construct($type);
$this->labels = array(
'nav' => _("Shared folder count: %s"),
'error_noneFound' => _("No shared folders found!"),
'newEntry' => _("New shared folder"),
'deleteEntry' => _("Delete selected shared folders"));
}
}
?>

View File

@ -569,3 +569,7 @@ h4.schema_oclass_sub {
.bind-bright { background:#b6eeff !important; } .bind-bright { background:#b6eeff !important; }
.bind-dark { background-color:#80e0e1 !important; } .bind-dark { background-color:#80e0e1 !important; }
.kolabSharedFolderType-border { border-color:#32768b; }
.kolabSharedFolderType-bright { background:#b6eeff !important; }
.kolabSharedFolderType-dark { background-color:#80e0e1 !important; }