using now emailadmin_smtp constants for internally used values for deliveryMode and accountStatus, fixing not working forward-only mode because of wrong case of values, ldap classes now ignore case to deal with existing data

This commit is contained in:
Ralf Becker 2012-11-20 14:01:58 +00:00
parent 42660ddfa1
commit 09e44d87fe
5 changed files with 37 additions and 33 deletions

View File

@ -22,13 +22,17 @@ class emailadmin_smtp
/**
* Attribute value to enable mail for an account, OR false if existense of attribute is enough to enable account
*
* Logical values uses inside EGroupware, different classes might store different values internally
*/
const MAIL_ENABLED = 'active';
/**
* Attribute value to only forward mail
*
* Logical values uses inside EGroupware, different classes might store different values internally
*/
const FORWARD_ONLY = 'forwardonly';
const FORWARD_ONLY = 'forwardOnly';
/**
* Reference to global account object

View File

@ -296,26 +296,26 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
// groups are always active (if they have an email) and allways forwardOnly
if (in_array('posixGroup', $values['objectclass']))
{
$accountStatus = 'active';
$deliveryMode = 'forwardOnly';
$accountStatus = emailadmin_smtp::MAIL_ENABLED;
$deliveryMode = emailadmin_smtp::FORWARD_ONLY;
}
else // for users we have to check the attributes
{
if ($this->config['mail_enable_attr'])
{
$accountStatus = isset($values[$this->config['mail_enable_attr']]) &&
($this->config['mail_enabled'] && $values[$this->config['mail_enable_attr']][0] == $this->config['mail_enabled'] ||
!$this->config['mail_enabled'] && $values[$this->config['alias_attr']]['count'] > 0) ? 'active' : '';
($this->config['mail_enabled'] && !strcasecmp($values[$this->config['mail_enable_attr']][0], $this->config['mail_enabled']) ||
!$this->config['mail_enabled'] && $values[$this->config['alias_attr']]['count'] > 0) ? emailadmin_smtp::MAIL_ENABLED : '';
}
else
{
$accountStatus = $values[$this->config['alias_attr']]['count'] > 0 ? 'active' : '';
$accountStatus = $values[$this->config['alias_attr']]['count'] > 0 ? emailadmin_smtp::MAIL_ENABLED : '';
}
if ($this->config['forward_only_attr'])
{
$deliveryMode = isset($values[$this->config['forward_only_attr']]) &&
($this->config['forward_only'] && $values[$this->config['forward_only_attr']][0] == $this->config['forward_only'] ||
!$this->config['forward_only'] && $values[$this->config['forward_only_attr']]['count'] > 0) ? 'forwardOnly' : '';
($this->config['forward_only'] && !strcasecmp($values[$this->config['forward_only_attr']][0], $this->config['forward_only']) ||
!$this->config['forward_only'] && $values[$this->config['forward_only_attr']]['count'] > 0) ? emailadmin_smtp::FORWARD_ONLY : '';
}
else
{
@ -327,7 +327,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
if ($accountStatus)
{
// groups never have a mailbox, accounts can have a deliveryMode of "forwardOnly"
if ($deliveryMode != 'forwardOnly')
if ($deliveryMode != emailadmin_smtp::FORWARD_ONLY)
{
$userData['uid'][] = $values['uid'][0];
if ($this->config['mailbox_attr'] && isset($values[$this->config['mailbox_attr']]))
@ -369,8 +369,8 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
if ($this->config['forward_only_attr'])
{
$userData['deliveryMode'] = isset($values[$this->config['forward_only_attr']]) &&
($this->config['forward_only'] && $values[$this->config['forward_only_attr']][0] == $this->config['forward_only'] ||
!$this->config['forward_only'] && $values[$this->config['forward_only_attr']]['count'] > 0) ? 'forwardOnly' : '';
($this->config['forward_only'] && !strcasecmp($values[$this->config['forward_only_attr']][0], $this->config['forward_only']) ||
!$this->config['forward_only'] && $values[$this->config['forward_only_attr']]['count'] > 0) ? emailadmin_smtp::FORWARD_ONLY : '';
}
else
{

View File

@ -157,8 +157,8 @@ class emailadmin_smtp_sql extends emailadmin_smtp
break;
case self::TYPE_DELIVERY:
$userData['deliveryMode'] = $row['mail_value'];
$forwardOnly[$row['account_id']] = $row['mail_value'] == self::FORWARD_ONLY;
$userData['deliveryMode'] = !strcasecmp($row['mail_value'], self::FORWARD_ONLY) ? emailadmin_smtp::FORWARD_ONLY : '';
$forwardOnly[$row['account_id']] = !strcasecmp($row['mail_value'], self::FORWARD_ONLY);
break;
case self::TYPE_QUOTA:

View File

@ -57,7 +57,7 @@ class postfixldap extends emailadmin_smtp_ldap
/**
* Attribute value to only forward mail
*/
const FORWARD_ONLY = 'forwardonly';
const FORWARD_ONLY = 'forwardOnly';
/**
* Attribute for mailbox, to which mail gets delivered OR false if not supported

View File

@ -25,7 +25,7 @@ class uiuserdata
* @var Template
*/
var $t;
/**
* @var emailadmin_bo
*/
@ -51,7 +51,7 @@ class uiuserdata
function editUserData($_useCache='0')
{
$accountID = $_GET['account_id'];
$accountID = $_GET['account_id'];
$GLOBALS['account_id'] = $accountID;
$this->display_app_header();
@ -88,7 +88,7 @@ class uiuserdata
$this->t->set_var('url_image_add',$GLOBALS['egw']->common->image('phpgwapi','new'));
$this->t->set_var('url_image_edit',$GLOBALS['egw']->common->image('phpgwapi','edit'));
$this->t->set_var('url_image_delete',$GLOBALS['egw']->common->image('phpgwapi','delete'));
// only when we show a existing user
if($userData = $this->boemailadmin->getUserData($accountID)) {
$addresses = array();
@ -103,7 +103,7 @@ class uiuserdata
"style='width: 100%;' id='mailAlternateAddress'",
5)
);
$addresses = array();
foreach((array)$userData['mailForwardingAddress'] as $data) {
$addresses[$data] = $data;
@ -116,21 +116,21 @@ class uiuserdata
"style='width: 100%;' id='mailRoutingAddress'",
5)
);
if (isset($userData["quotaUsed"]) && $userData["quotaUsed"]>0) $this->t->set_var('lang_qoutainmbyte',lang('qouta size in MByte').'<br><b><i>('.(int)$userData["quotaUsed"].' '.lang('MB used').')</i></b>');
if (isset($userData["quotaUsed"]) && $userData["quotaUsed"]>0) $this->t->set_var('lang_qoutainmbyte',lang('qouta size in MByte').'<br><b><i>('.(int)$userData["quotaUsed"].' '.lang('MB used').')</i></b>');
$this->t->set_var("quotaLimit",$userData["quotaLimit"]);
$this->t->set_var("mailLocalAddress",$userData["mailLocalAddress"]);
$this->t->set_var("mailAlternateAddress",'');
$this->t->set_var("mailRoutingAddress",'');
$this->t->set_var("selected_".$userData["qmailDotMode"],'selected');
$this->t->set_var("deliveryProgramPath",$userData["deliveryProgramPath"]);
$this->t->set_var("uid",rawurlencode($_accountData["dn"]));
if ($userData["accountStatus"] == "active")
if ($userData["accountStatus"] == emailadmin_smtp::MAIL_ENABLED)
$this->t->set_var("account_checked","checked");
if ($userData["deliveryMode"] == "forwardOnly")
if ($userData["deliveryMode"] == emailadmin_smtp::FORWARD_ONLY)
$this->t->set_var("forwardOnly_checked","checked");
if ($_accountData["deliverExtern"] == "active")
if ($_accountData["deliverExtern"] == emailadmin_smtp::MAIL_ENABLED)
$this->t->set_var("deliver_checked","checked");
} else {
$this->t->set_var("mailLocalAddress",'');
@ -149,7 +149,7 @@ class uiuserdata
"style='width: 100%;' id='mailAlternateAddress'",
5)
);
$this->t->set_var('selectbox_mailRoutingAddress', html::select(
'mailForwardingAddress',
'',
@ -158,26 +158,26 @@ class uiuserdata
"style='width: 100%;' id='mailRoutingAddress'",
5)
);
$this->t->set_var('quotaLimit','');
}
// create the menu on the left, if needed
// create the menu on the left, if needed
$menuClass =& CreateObject('admin.uimenuclass');
$this->t->set_var('rows',$menuClass->createHTMLCode('edit_user'));
$this->t->pparse("out","form");
}
function saveUserData()
{
if($_POST["accountStatus"] == "on") {
$accountStatus = "active";
$accountStatus = emailadmin_smtp::MAIL_ENABLED;
}
if($_POST["forwardOnly"] == "on") {
$deliveryMode = "forwardOnly";
$deliveryMode = emailadmin_smtp::FORWARD_ONLY;
}
$formData = array (
@ -196,7 +196,7 @@ class uiuserdata
// read date fresh from ldap storage
$this->editUserData();
}
function translate()
{
$this->t->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);