made Kolab optional

This commit is contained in:
Roland Gruber 2008-11-18 19:03:10 +00:00
parent e9d18cd1bc
commit 6e48ecdb47
1 changed files with 274 additions and 278 deletions

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2004 - 2006 Roland Gruber Copyright (C) 2004 - 2008 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -43,6 +43,8 @@ class kolabUser extends baseModule {
* @param string $scope account type (user, group, host) * @param string $scope account type (user, group, host)
*/ */
function __construct($scope) { function __construct($scope) {
// call parent constructor
parent::__construct($scope);
// list of invitation policies // list of invitation policies
$this->invitationPolicies = array( $this->invitationPolicies = array(
'ACT_ALWAYS_ACCEPT' => _('Always accept'), 'ACT_ALWAYS_ACCEPT' => _('Always accept'),
@ -51,8 +53,7 @@ class kolabUser extends baseModule {
'ACT_REJECT_IF_CONFLICTS' => _('Reject if conflicts'), 'ACT_REJECT_IF_CONFLICTS' => _('Reject if conflicts'),
'ACT_MANUAL_IF_CONFLICTS' => _('Manual if conflicts') 'ACT_MANUAL_IF_CONFLICTS' => _('Manual if conflicts')
); );
// call parent constructor $this->autoAddObjectClasses = false;
parent::__construct($scope);
} }
/** /**
@ -258,41 +259,24 @@ class kolabUser extends baseModule {
$this->messages['quota'][1] = array('ERROR', _('Account %s:') . ' kolabUser_quota', _('Mail quota must be a number!')); $this->messages['quota'][1] = array('ERROR', _('Account %s:') . ' kolabUser_quota', _('Mail quota must be a number!'));
} }
/**
* 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
*/
function save_attributes() {
// add object class if needed
if (!isset($this->attributes['objectClass']) || !in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'kolabInetOrgPerson';
}
return parent::save_attributes();
}
/** /**
* Returns the HTML meta data for the main account page. * Returns the HTML meta data for the main account page.
* *
* @return array HTML meta data * @return array HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
$return = array();
if (isset($this->attributes['objectClass']) && in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) {
$attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); $attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) {
$attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); $attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if (!$attrsP['userPassword'][0]) { if (!isset($attrsP['userPassword'][0]) || ($attrsP['userPassword'][0] == '')) {
StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('posixAccount')->get_alias())); StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('posixAccount')->get_alias()));
} }
} }
elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) { elseif ($this->getAccountContainer()->getAccountModule('inetOrgPerson') != null) {
if (!$attrsI['userPassword'][0]) { if (!isset($attrsI['userPassword'][0]) || ($attrsI['userPassword'][0] == '')) {
StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); StatusMessage('ERROR', _("Please enter a user password on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias()));
} }
} }
@ -300,7 +284,6 @@ class kolabUser extends baseModule {
if (!$attrsI['mail'][0]) { if (!$attrsI['mail'][0]) {
StatusMessage('ERROR', _("Please enter an email address on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias())); StatusMessage('ERROR', _("Please enter an email address on this page: %s"), '', array($this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias()));
} }
$return = array();
// check if account is marked for deletion // check if account is marked for deletion
if (isset($this->attributes['kolabDeleteflag'])) { if (isset($this->attributes['kolabDeleteflag'])) {
$return[] = array( $return[] = array(
@ -419,12 +402,18 @@ class kolabUser extends baseModule {
// delete flag // delete flag
if (!$this->getAccountContainer()->isNewAccount) { if (!$this->getAccountContainer()->isNewAccount) {
$returnDelete = array( $returnDelete = array(
0 => array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_deleteUser_open'), array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_deleteUser_open'),
1 => array('kind' => 'help', 'value' => 'deleteFlag')); array('kind' => 'help', 'value' => 'deleteFlag'));
$return[] = array( $return[] = array(
array('kind' => 'fieldset', 'legend' => _('Delete Kolab account'), 'value' => array($returnDelete), 'td' => array('colspan' => 3)) array('kind' => 'fieldset', 'legend' => _('Delete Kolab account'), 'value' => array($returnDelete), 'td' => array('colspan' => 3))
); );
} }
}
else {
$return[] = array(
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_kolabUser_attributes_addObjectClass', 'value' => _('Add Kolab extension'))
);
}
return $return; return $return;
} }
@ -436,6 +425,10 @@ class kolabUser extends baseModule {
*/ */
function process_attributes() { function process_attributes() {
$errors = array(); $errors = array();
if (isset($_POST['form_subpage_kolabUser_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'kolabInetOrgPerson';
}
else {
if ($_POST['form_subpage_kolabUser_deleteUser_open']) return array(); if ($_POST['form_subpage_kolabUser_deleteUser_open']) return array();
$this->attributes['kolabInvitationPolicy'] = array(); $this->attributes['kolabInvitationPolicy'] = array();
// country // country
@ -572,6 +565,7 @@ class kolabUser extends baseModule {
$errors[] = $message; $errors[] = $message;
} }
} }
}
return $errors; return $errors;
} }
@ -581,12 +575,12 @@ class kolabUser extends baseModule {
function display_html_deleteUser() { function display_html_deleteUser() {
$return = array(); $return = array();
$return[] = array( $return[] = array(
0 => array('kind' => 'text', 'text' => _('Do you really want to mark this account for deletion?'), 'td' => array('colspan' => 2))); array('kind' => 'text', 'text' => _('Do you really want to mark this account for deletion?'), 'td' => array('colspan' => 2)));
$return[] = array( $return[] = array(
0 => array('kind' => 'text', 'text' => ' ', 'td' => array('colspan' => 2))); array('kind' => 'text', 'text' => ' ', 'td' => array('colspan' => 2)));
$return[] = array( $return[] = array(
0 => array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_attributes_confirm'), array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_attributes_confirm'),
1 => array('kind' => 'input', 'type' => 'submit', 'value' => _('Cancel'), 'name' => 'form_subpage_kolabUser_attributes_cancel')); array('kind' => 'input', 'type' => 'submit', 'value' => _('Cancel'), 'name' => 'form_subpage_kolabUser_attributes_cancel'));
return $return; return $return;
} }
@ -606,6 +600,7 @@ class kolabUser extends baseModule {
* @return true, if account can be saved * @return true, if account can be saved
*/ */
function module_complete() { function module_complete() {
if (isset($this->attributes['objectClass']) && in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) {
$attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes(); $attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
$attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); $attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if (!$attrsI['mail'][0]) return false; if (!$attrsI['mail'][0]) return false;
@ -617,6 +612,7 @@ class kolabUser extends baseModule {
if (!$attrsI['userPassword'][0]) return false; if (!$attrsI['userPassword'][0]) return false;
} }
} }
}
return true; return true;
} }