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$
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
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)
*/
function __construct($scope) {
// call parent constructor
parent::__construct($scope);
// list of invitation policies
$this->invitationPolicies = array(
'ACT_ALWAYS_ACCEPT' => _('Always accept'),
@ -51,8 +53,7 @@ class kolabUser extends baseModule {
'ACT_REJECT_IF_CONFLICTS' => _('Reject if conflicts'),
'ACT_MANUAL_IF_CONFLICTS' => _('Manual if conflicts')
);
// call parent constructor
parent::__construct($scope);
$this->autoAddObjectClasses = false;
}
/**
@ -258,41 +259,24 @@ class kolabUser extends baseModule {
$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.
*
* @return array HTML meta data
*/
function display_html_attributes() {
$return = array();
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 (!$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()));
}
}
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()));
}
}
@ -300,7 +284,6 @@ class kolabUser extends baseModule {
if (!$attrsI['mail'][0]) {
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
if (isset($this->attributes['kolabDeleteflag'])) {
$return[] = array(
@ -419,12 +402,18 @@ class kolabUser extends baseModule {
// delete flag
if (!$this->getAccountContainer()->isNewAccount) {
$returnDelete = array(
0 => array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_deleteUser_open'),
1 => array('kind' => 'help', 'value' => 'deleteFlag'));
array('kind' => 'input', 'type' => 'submit', 'value' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_deleteUser_open'),
array('kind' => 'help', 'value' => 'deleteFlag'));
$return[] = array(
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;
}
@ -436,6 +425,10 @@ class kolabUser extends baseModule {
*/
function process_attributes() {
$errors = array();
if (isset($_POST['form_subpage_kolabUser_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'kolabInetOrgPerson';
}
else {
if ($_POST['form_subpage_kolabUser_deleteUser_open']) return array();
$this->attributes['kolabInvitationPolicy'] = array();
// country
@ -572,6 +565,7 @@ class kolabUser extends baseModule {
$errors[] = $message;
}
}
}
return $errors;
}
@ -581,12 +575,12 @@ class kolabUser extends baseModule {
function display_html_deleteUser() {
$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(
0 => array('kind' => 'text', 'text' => ' ', 'td' => array('colspan' => 2)));
array('kind' => 'text', 'text' => ' ', 'td' => array('colspan' => 2)));
$return[] = array(
0 => 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' => _('Mark account for deletion'), 'name' => 'form_subpage_kolabUser_attributes_confirm'),
array('kind' => 'input', 'type' => 'submit', 'value' => _('Cancel'), 'name' => 'form_subpage_kolabUser_attributes_cancel'));
return $return;
}
@ -606,6 +600,7 @@ class kolabUser extends baseModule {
* @return true, if account can be saved
*/
function module_complete() {
if (isset($this->attributes['objectClass']) && in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) {
$attrsI = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->getAttributes();
$attrsP = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
if (!$attrsI['mail'][0]) return false;
@ -617,6 +612,7 @@ class kolabUser extends baseModule {
if (!$attrsI['userPassword'][0]) return false;
}
}
}
return true;
}