remove superfluous globals, format

This commit is contained in:
Miles Lott 2005-11-26 14:04:40 +00:00
parent 2a44512e96
commit a828b3cf85
3 changed files with 178 additions and 198 deletions

View File

@ -17,9 +17,9 @@
{ {
var $sessionData; var $sessionData;
var $LDAPData; var $LDAPData;
var $SMTPServerType = array(); // holds a list of config options var $SMTPServerType = array(); // holds a list of config options
var $imapClass; // holds the imap/pop3 class var $imapClass; // holds the imap/pop3 class
var $smtpClass; // holds the smtp class var $smtpClass; // holds the smtp class
@ -37,7 +37,7 @@
function boldap_mgr($_profileID=-1) function boldap_mgr($_profileID=-1)
{ {
$this->soldapmgr =& CreateObject('admin.soldap_mgr'); $this->soldapmgr =& CreateObject('admin.soldap_mgr');
$this->SMTPServerType = array( $this->SMTPServerType = array(
'1' => array( '1' => array(
'fieldNames' => array( 'fieldNames' => array(
@ -115,16 +115,16 @@
'protocol' => 'imap', 'protocol' => 'imap',
'classname' => 'cyrusimap' 'classname' => 'cyrusimap'
) )
); );
$this->restoreSessionData(); $this->restoreSessionData();
if($_profileID >= 0) if($_profileID >= 0)
{ {
$this->profileID = $_profileID; $this->profileID = $_profileID;
$this->profileData = $this->getProfile($_profileID); $this->profileData = $this->getProfile($_profileID);
$this->imapClass = $this->IMAPServerType[$this->profileData['imapType']]['classname']; $this->imapClass = $this->IMAPServerType[$this->profileData['imapType']]['classname'];
$this->smtpClass = $this->SMTPServerType[$this->profileData['smtpType']]['classname']; $this->smtpClass = $this->SMTPServerType[$this->profileData['smtpType']]['classname'];
} }
@ -134,20 +134,20 @@
{ {
switch($_encoding) switch($_encoding)
{ {
case "q": case 'q':
if(!preg_match("/[\x80-\xFF]/",$_string)) if(!preg_match("/[\x80-\xFF]/",$_string))
{ {
// nothing to quote, only 7 bit ascii // nothing to quote, only 7 bit ascii
return $_string; return $_string;
} }
$string = imap_8bit($_string); $string = imap_8bit($_string);
$stringParts = explode("=\r\n",$string); $stringParts = explode("=\r\n",$string);
while(list($key,$value) = each($stringParts)) while(list($key,$value) = each($stringParts))
{ {
if(!empty($retString)) $retString .= " "; if(!empty($retString)) $retString .= ' ';
$value = str_replace(" ","_",$value); $value = str_replace(' ','_',$value);
// imap_8bit does not convert "?" // imap_8bit does not convert '?'
// it does not need, but it should // it does not need, but it should
$value = str_replace("?","=3F",$value); $value = str_replace("?","=3F",$value);
$retString .= "=?".strtoupper($this->displayCharset)."?Q?".$value."?="; $retString .= "=?".strtoupper($this->displayCharset)."?Q?".$value."?=";
@ -163,12 +163,12 @@
function getAccountEmailAddress($_accountName, $_profileID) function getAccountEmailAddress($_accountName, $_profileID)
{ {
$profileData = $this->getProfile($_profileID); $profileData = $this->getProfile($_profileID);
$smtpClass = $this->SMTPServerType[$profileData['smtpType']]['classname']; $smtpClass = $this->SMTPServerType[$profileData['smtpType']]['classname'];
return empty($smtpClass) ? False : ExecMethod("emailadmin.$smtpClass.getAccountEmailAddress",$_accountName,3,$profileData); return empty($smtpClass) ? False : ExecMethod("emailadmin.$smtpClass.getAccountEmailAddress",$_accountName,3,$profileData);
} }
function getFieldNames($_serverTypeID, $_class) function getFieldNames($_serverTypeID, $_class)
{ {
switch($_class) switch($_class)
@ -181,7 +181,7 @@
break; break;
} }
} }
# function getIMAPClass($_profileID) # function getIMAPClass($_profileID)
# { # {
# if(!is_object($this->imapClass)) # if(!is_object($this->imapClass))
@ -189,10 +189,10 @@
# $profileData = $this->getProfile($_profileID); # $profileData = $this->getProfile($_profileID);
# $this->imapClass =& CreateObject('emailadmin.cyrusimap',$profileData); # $this->imapClass =& CreateObject('emailadmin.cyrusimap',$profileData);
# } # }
# #
# return $this->imapClass; # return $this->imapClass;
# } # }
function getIMAPServerTypes() function getIMAPServerTypes()
{ {
foreach($this->IMAPServerType as $key => $value) foreach($this->IMAPServerType as $key => $value)
@ -200,21 +200,21 @@
$retData[$key]['description'] = $value['description']; $retData[$key]['description'] = $value['description'];
$retData[$key]['protocol'] = $value['protocol']; $retData[$key]['protocol'] = $value['protocol'];
} }
return $retData; return $retData;
} }
function getLDAPStorageData($_serverid) function getLDAPStorageData($_serverid)
{ {
$storageData = $this->soldapmgr->getLDAPStorageData($_serverid); $storageData = $this->soldapmgr->getLDAPStorageData($_serverid);
return $storageData; return $storageData;
} }
function getMailboxString($_folderName) function getMailboxString($_folderName)
{ {
if (!empty($this->imapClass)) if (!empty($this->imapClass))
{ {
return ExecMethod("emailadmin.".$this->imapClass.".getMailboxString",$_folderName,3,$this->profileData); return ExecMethod('emailadmin.'.$this->imapClass.'.getMailboxString',$_folderName,3,$this->profileData);
} }
else else
{ {
@ -232,16 +232,16 @@
$fieldNames[] = 'profileID'; $fieldNames[] = 'profileID';
$fieldNames[] = 'organisationName'; $fieldNames[] = 'organisationName';
$fieldNames[] = 'userDefinedAccounts'; $fieldNames[] = 'userDefinedAccounts';
return $this->soldapmgr->getProfile($_profileID, $fieldNames); return $this->soldapmgr->getProfile($_profileID, $fieldNames);
} }
function getProfileList($_profileID='') function getProfileList($_profileID='')
{ {
$profileList = $this->soldapmgr->getProfileList($_profileID); $profileList = $this->soldapmgr->getProfileList($_profileID);
return $profileList; return $profileList;
} }
# function getSMTPClass($_profileID) # function getSMTPClass($_profileID)
# { # {
# if(!is_object($this->smtpClass)) # if(!is_object($this->smtpClass))
@ -249,20 +249,20 @@
# $profileData = $this->getProfile($_profileID); # $profileData = $this->getProfile($_profileID);
# $this->smtpClass =& CreateObject('emailadmin.postfixldap',$profileData); # $this->smtpClass =& CreateObject('emailadmin.postfixldap',$profileData);
# } # }
# #
# return $this->smtpClass; # return $this->smtpClass;
# } # }
function getSMTPServerTypes() function getSMTPServerTypes()
{ {
foreach($this->SMTPServerType as $key => $value) foreach($this->SMTPServerType as $key => $value)
{ {
$retData[$key] = $value['description']; $retData[$key] = $value['description'];
} }
return $retData; return $retData;
} }
function getUserData($_accountID, $_usecache) function getUserData($_accountID, $_usecache)
{ {
if ($_usecache) if ($_usecache)
@ -280,18 +280,16 @@
function restoreSessionData() function restoreSessionData()
{ {
$this->sessionData = $GLOBALS['egw']->session->appsession('session_data'); $this->sessionData = $GLOBALS['egw']->session->appsession('session_data');
$this->userSessionData = $GLOBALS['egw']->session->appsession('user_session_data'); $this->userSessionData = $GLOBALS['egw']->session->appsession('user_session_data');
#while(list($key, $value) = each($this->userSessionData)) #while(list($key, $value) = each($this->userSessionData))
#{ #{
# print "++ $key: $value<br>"; # print "++ $key: $value<br>";
#} #}
#print "restored Session<br>"; #print "restored Session<br>";
} }
function saveProfile($_globalSettings, $_smtpSettings, $_imapSettings) function saveProfile($_globalSettings, $_smtpSettings, $_imapSettings)
{ {
if(!isset($_globalSettings['profileID'])) if(!isset($_globalSettings['profileID']))
@ -304,29 +302,17 @@
} }
} }
function saveSessionData() function saveSessionData()
{ {
$GLOBALS['egw']->session->appsession('session_data','',$this->sessionData); $GLOBALS['egw']->session->appsession('session_data','',$this->sessionData);
$GLOBALS['egw']->session->appsession('user_session_data','',$this->userSessionData); $GLOBALS['egw']->session->appsession('user_session_data','',$this->userSessionData);
} }
function saveUserData($_accountID, $_formData, $_boAction) function saveUserData($_accountID, $_formData, $_boAction)
{ {
$this->userSessionData[$_accountID]['mail'] = $_formData["mail"]; $this->userSessionData[$_accountID]['mail'] = $_formData['mail'];
$this->userSessionData[$_accountID]['mailForwardingAddress'] = $_formData["mailForwardingAddress"]; $this->userSessionData[$_accountID]['mailForwardingAddress'] = $_formData['mailForwardingAddress'];
$this->userSessionData[$_accountID]['accountStatus'] = $_formData["accountStatus"]; $this->userSessionData[$_accountID]['accountStatus'] = $_formData['accountStatus'];
switch ($_boAction) switch ($_boAction)
{ {
@ -341,17 +327,17 @@
//ACHTUNG!! //ACHTUNG!!
$count = 0; $count = 0;
} }
$this->userSessionData[$_accountID]['mailAlternateAddress'][$count] = $this->userSessionData[$_accountID]['mailAlternateAddress'][$count] =
$_formData['add_mailAlternateAddress']; $_formData['add_mailAlternateAddress'];
$this->saveSessionData(); $this->saveSessionData();
break; break;
case 'remove_mailAlternateAddress': case 'remove_mailAlternateAddress':
$i=0; $i=0;
while(list($key, $value) = @each($this->userSessionData[$_accountID]['mailAlternateAddress'])) while(list($key, $value) = @each($this->userSessionData[$_accountID]['mailAlternateAddress']))
{ {
#print ".. $key: $value<br>"; #print ".. $key: $value<br>";
@ -363,23 +349,25 @@
} }
} }
$this->userSessionData[$_accountID]['mailAlternateAddress'] = $newMailAlternateAddress; $this->userSessionData[$_accountID]['mailAlternateAddress'] = $newMailAlternateAddress;
$this->saveSessionData(); $this->saveSessionData();
break; break;
case 'save': case 'save':
$this->soldapmgr->saveUserData( $this->soldapmgr->saveUserData(
$_accountID, $_accountID,
$this->userSessionData[$_accountID]); $this->userSessionData[$_accountID]
);
$bofelamimail =& CreateObject('felamimail.bofelamimail'); $bofelamimail =& CreateObject('felamimail.bofelamimail');
$bofelamimail->openConnection('','',true); $bofelamimail->openConnection('','',true);
$bofelamimail->imapSetQuota($GLOBALS['egw']->accounts->id2name($_accountID), $bofelamimail->imapSetQuota(
$this->userSessionData[$_accountID]['quotaLimit']); $GLOBALS['egw']->accounts->id2name($_accountID),
$this->userSessionData[$_accountID]['quotaLimit']
);
$bofelamimail->closeConnection(); $bofelamimail->closeConnection();
$GLOBALS['egw']->accounts->cache_invalidate($_accountID); $GLOBALS['egw']->accounts->cache_invalidate($_accountID);
break; break;
} }
} }
@ -388,14 +376,13 @@
{ {
if (!empty($this->imapClass)) if (!empty($this->imapClass))
{ {
ExecMethod("emailadmin.".$this->imapClass.".updateAccount",$_hookValues,3,$this->profileData); ExecMethod('emailadmin.'.$this->imapClass.'.updateAccount',$_hookValues,3,$this->profileData);
} }
if (!empty($this->smtpClass)) if (!empty($this->smtpClass))
{ {
ExecMethod("emailadmin.".$this->smtpClass.".updateAccount",$_hookValues,3,$this->profileData); ExecMethod('emailadmin.'.$this->smtpClass.'.updateAccount',$_hookValues,3,$this->profileData);
} }
} }
} }
?> ?>

View File

@ -1,62 +1,58 @@
<?php <?php
/***************************************************************************\ /***************************************************************************\
* EGroupWare - LDAPManager * * EGroupWare - LDAPManager *
* http://www.egroupware.org * * http://www.egroupware.org *
* Written by : Andreas Krause (ak703@users.sourceforge.net * * Written by : Andreas Krause (ak703@users.sourceforge.net *
* based on EmailAdmin by Lars Kneschke [lkneschke@egroupware.org] * * based on EmailAdmin by Lars Kneschke [lkneschke@egroupware.org] *
* ------------------------------------------------- * * ------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. * * option) any later version. *
\***************************************************************************/ \***************************************************************************/
class soldap_mgr class soldap_mgr
{ {
function soldap_mgr() function soldap_mgr()
{ {
$this->db = clone($GLOBALS['egw']->db); $this->db = clone($GLOBALS['egw']->db);
include(EGW_INCLUDE_ROOT.'/emailadmin/setup/tables_current.inc.php'); include(EGW_INCLUDE_ROOT.'/emailadmin/setup/tables_current.inc.php');
$this->tables = &$phpgw_baseline; $this->tables = &$phpgw_baseline;
unset($phpgw_baseline); unset($phpgw_baseline);
$this->table = &$this->tables['phpgw_emailadmin']; $this->table = &$this->tables['phpgw_emailadmin'];
} }
function getUserData($_accountID) function getUserData($_accountID)
{ {
global $phpgw, $phpgw_info;
$ldap = $GLOBALS['egw']->common->ldapConnect(); $ldap = $GLOBALS['egw']->common->ldapConnect();
$filter = "(&(uidnumber=$_accountID))"; $filter = "(&(uidnumber=$_accountID))";
$sri = @ldap_search($ldap,$GLOBALS['egw_info']['server']['ldap_context'],$filter); $sri = @ldap_search($ldap,$GLOBALS['egw_info']['server']['ldap_context'],$filter);
if ($sri) if ($sri)
{ {
$allValues = ldap_get_entries($ldap, $sri); $allValues = ldap_get_entries($ldap, $sri);
if ($allValues['count'] > 0) if ($allValues['count'] > 0)
{ {
#print "found something<br>"; #print 'found something<br>';
$userData["mail"] = $allValues[0]["mail"][0]; $userData['mail'] = $allValues[0]['mail'][0];
$userData["mailAlternateAddress"] = $allValues[0]["mailalternateaddress"]; $userData['mailAlternateAddress'] = $allValues[0]['mailalternateaddress'];
$userData["accountStatus"] = $allValues[0]["accountstatus"][0]; $userData['accountStatus'] = $allValues[0]['accountstatus'][0];
$userData["mailForwardingAddress"] = $allValues[0]["mailforwardingaddress"][0]; $userData['mailForwardingAddress'] = $allValues[0]['mailforwardingaddress'][0];
$userData["deliveryMode"] = $allValues[0]["deliverymode"][0]; $userData['deliveryMode'] = $allValues[0]['deliverymode'][0];
unset($userData["mailAlternateAddress"]["count"]); unset($userData['mailAlternateAddress']['count']);
unset($userData["mailForwardingAddress"]["count"]); unset($userData['mailForwardingAddress']['count']);
return $userData; return $userData;
} }
} }
// if we did not return before, return false // if we did not return before, return false
return false; return false;
} }
function saveUserData($_accountID, $_accountData) function saveUserData($_accountID, $_accountData)
{ {
$ldap = $GLOBALS['egw']->common->ldapConnect(); $ldap = $GLOBALS['egw']->common->ldapConnect();
// need to be fixed // need to be fixed
if(is_numeric($_accountID)) if(is_numeric($_accountID))
@ -76,57 +72,57 @@
$uid = $allValues[0]['uid'][0]; $uid = $allValues[0]['uid'][0];
$homedirectory = $allValues[0]['homedirectory'][0]; $homedirectory = $allValues[0]['homedirectory'][0];
$objectClasses = $allValues[0]['objectclass']; $objectClasses = $allValues[0]['objectclass'];
unset($objectClasses['count']); unset($objectClasses['count']);
} }
else else
{ {
return false; return false;
} }
if(empty($homedirectory)) if(empty($homedirectory))
{ {
$homedirectory = "/home/".$uid; $homedirectory = "/home/".$uid;
} }
// the old code for qmail ldap // the old code for qmail ldap
$newData = array $newData = array
( (
'mail' => $_accountData["mail"], 'mail' => $_accountData['mail'],
'mailAlternateAddress' => $_accountData["mailAlternateAddress"], 'mailAlternateAddress' => $_accountData['mailAlternateAddress'],
'mailForwardingAddress' => $_accountData["mailForwardingAddress"], 'mailForwardingAddress' => $_accountData['mailForwardingAddress'],
// 'homedirectory' => $homedirectory, // 'homedirectory' => $homedirectory,
// 'mailMessageStore' => $homedirectory."/Maildir/", // 'mailMessageStore' => $homedirectory.'/Maildir/',
// 'gidnumber' => '1000', // 'gidnumber' => '1000',
// 'qmailDotMode' => $_accountData["qmailDotMode"], // 'qmailDotMode' => $_accountData['qmailDotMode'],
// 'deliveryProgramPath' => $_accountData["deliveryProgramPath"] // 'deliveryProgramPath' => $_accountData['deliveryProgramPath']
); );
if(!in_array('qmailUser',$objectClasses) && if(!in_array('qmailUser',$objectClasses) &&
!in_array('qmailuser',$objectClasses)) !in_array('qmailuser',$objectClasses))
{ {
$objectClasses[] = 'qmailuser'; $objectClasses[] = 'qmailuser';
} }
// the new code for postfix+cyrus+ldap // the new code for postfix+cyrus+ldap
$newData = array $newData = array
( (
'mail' => $_accountData["mail"], 'mail' => $_accountData['mail'],
'accountStatus' => $_accountData["accountStatus"], 'accountStatus' => $_accountData['accountStatus'],
'objectclass' => $objectClasses 'objectclass' => $objectClasses
); );
if(is_array($_accountData["mailAlternateAddress"])) if(is_array($_accountData['mailAlternateAddress']))
{ {
$newData['mailAlternateAddress'] = $_accountData["mailAlternateAddress"]; $newData['mailAlternateAddress'] = $_accountData['mailAlternateAddress'];
} }
else else
{ {
$newData['mailAlternateAddress'] = array(); $newData['mailAlternateAddress'] = array();
} }
if($_accountData["accountStatus"] == 'active') if($_accountData['accountStatus'] == 'active')
{ {
$newData['accountStatus'] = 'active'; $newData['accountStatus'] = 'active';
} }
else else
@ -134,9 +130,9 @@
$newData['accountStatus'] = 'disabled'; $newData['accountStatus'] = 'disabled';
} }
/* /*
if(!empty($_accountData["deliveryMode"])) if(!empty($_accountData['deliveryMode']))
{ {
$newData['deliveryMode'] = $_accountData["deliveryMode"]; $newData['deliveryMode'] = $_accountData['deliveryMode'];
} }
else else
{ {
@ -144,24 +140,24 @@
} }
*/ */
// if(is_array($_accountData["mailForwardingAddress"])) // if(is_array($_accountData['mailForwardingAddress']))
// { // {
$newData['mailForwardingAddress'] = $_accountData["mailForwardingAddress"]; $newData['mailForwardingAddress'] = $_accountData['mailForwardingAddress'];
// } // }
// else // else
// { // {
// $newData['mailForwardingAddress'] = array(); // $newData['mailForwardingAddress'] = array();
// } // }
#print "<br>DN: $accountDN<br>"; #print "<br>DN: $accountDN<br>";
ldap_mod_replace ($ldap, $accountDN, $newData); ldap_mod_replace ($ldap, $accountDN, $newData);
// also update the account_email field in egw_accounts // also update the account_email field in egw_accounts
// when using sql account storage // when using sql account storage
if($GLOBALS['egw_info']['server']['account_repository'] == 'sql') if($GLOBALS['egw_info']['server']['account_repository'] == 'sql')
{ {
$this->db->update('egw_accounts',array( $this->db->update('egw_accounts',array(
'account_email' => $_accountData["mail"] 'account_email' => $_accountData['mail']
), ),
array( array(
'account_id' => $_accountID 'account_id' => $_accountID

View File

@ -1,9 +1,9 @@
<?php <?php
/***************************************************************************\ /***************************************************************************\
* EGroupWare - LDAPManager * * EGroupWare - LDAPManager *
* http://www.egroupware.org * * http://www.egroupware.org *
* Written by : Andreas Krause (ak703@users.sourceforge.net * * Written by : Andreas Krause (ak703@users.sourceforge.net *
* based on EmailAdmin by Lars Kneschke [lkneschke@egroupware.org] * * based on EmailAdmin by Lars Kneschke [lkneschke@egroupware.org] *
* ------------------------------------------------- * * ------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it * * 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 * * under the terms of the GNU General Public License as published by the *
@ -16,72 +16,68 @@
var $public_functions = array var $public_functions = array
( (
'editUserData' => True, 'editUserData' => True,
'saveUserData' => True 'saveUserData' => True
); );
function uildap_mgr() function uildap_mgr()
{ {
$this->t =& CreateObject('phpgwapi.Template',EGW_APP_TPL); $this->t =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
$this->boldapmgr =& CreateObject('admin.boldap_mgr'); $this->boldapmgr =& CreateObject('admin.boldap_mgr');
} }
function display_app_header() function display_app_header()
{ {
$GLOBALS['egw']->common->egw_header(); $GLOBALS['egw']->common->egw_header();
echo parse_navbar(); echo parse_navbar();
} }
function editUserData($_useCache='0') function editUserData($_useCache='0')
{ {
global $phpgw, $phpgw_info, $_GET; $accountID = $_GET['account_id'];
$accountID = $_GET['account_id'];
$GLOBALS['account_id'] = $accountID; $GLOBALS['account_id'] = $accountID;
$this->display_app_header(); $this->display_app_header();
$this->translate(); $this->translate();
$this->t->set_file(array("editUserData" => "account_form_ldapdata.tpl")); $this->t->set_file(array('editUserData' => 'account_form_ldapdata.tpl'));
$this->t->set_block('editUserData','form','form'); $this->t->set_block('editUserData','form','form');
$this->t->set_block('editUserData','link_row','link_row'); $this->t->set_block('editUserData','link_row','link_row');
$this->t->set_var("th_bg",$GLOBALS['egw_info']["theme"]["th_bg"]); $this->t->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
$this->t->set_var("tr_color1",$GLOBALS['egw_info']["theme"]["row_on"]); $this->t->set_var('tr_color1',$GLOBALS['egw_info']['theme']['row_on']);
$this->t->set_var("tr_color2",$GLOBALS['egw_info']["theme"]["row_off"]); $this->t->set_var('tr_color2',$GLOBALS['egw_info']['theme']['row_off']);
$this->t->set_var("lang_email_config",lang("edit email settings")); $this->t->set_var('lang_email_config',lang('edit email settings'));
$this->t->set_var("lang_emailAddress",lang("email address")); $this->t->set_var('lang_emailAddress',lang('email address'));
$this->t->set_var("lang_emailaccount_active",lang("email account active")); $this->t->set_var('lang_emailaccount_active',lang('email account active'));
$this->t->set_var("lang_mailAlternateAddress",lang("alternate email address")); $this->t->set_var('lang_mailAlternateAddress',lang('alternate email address'));
$this->t->set_var("lang_mailForwardingAddress",lang("forward email's to")); $this->t->set_var('lang_mailForwardingAddress',lang('forward emails to'));
$this->t->set_var("lang_forward_also_to",lang("forward also to")); $this->t->set_var('lang_forward_also_to',lang('forward also to'));
$this->t->set_var("lang_button",lang("save")); $this->t->set_var('lang_button',lang('save'));
$this->t->set_var("lang_deliver_extern",lang("deliver extern")); $this->t->set_var('lang_deliver_extern',lang('deliver extern'));
$this->t->set_var("lang_edit_email_settings",lang("edit email settings")); $this->t->set_var('lang_edit_email_settings',lang('edit email settings'));
$this->t->set_var("lang_ready",lang("Done")); $this->t->set_var('lang_ready',lang('Done'));
$this->t->set_var("link_back",$GLOBALS['egw']->link('/admin/accounts.php')); $this->t->set_var('link_back',$GLOBALS['egw']->link('/admin/accounts.php'));
$this->t->set_var("info_icon",EGW_IMAGES_DIR.'/info.gif'); $this->t->set_var('info_icon',EGW_IMAGES_DIR.'/info.gif');
$linkData = array $linkData = array
( (
'menuaction' => 'admin.uildap_mgr.saveUserData', 'menuaction' => 'admin.uildap_mgr.saveUserData',
'account_id' => $accountID 'account_id' => $accountID
); );
$this->t->set_var("form_action", $GLOBALS['egw']->link('/index.php',$linkData)); $this->t->set_var('form_action', $GLOBALS['egw']->link('/index.php',$linkData));
// only when we show a existing user // only when we show a existing user
if($userData = $this->boldapmgr->getUserData($accountID, $_useCache)) if($userData = $this->boldapmgr->getUserData($accountID, $_useCache))
{ {
echo "<br><br><br>"; echo '<br><br><br>';
if ($userData['mailAlternateAddress'] != '') if ($userData['mailAlternateAddress'] != '')
{ {
$options_mailAlternateAddress = "<select size=\"6\" name=\"mailAlternateAddress\">\n"; $options_mailAlternateAddress = '<select size="6" name="mailAlternateAddress">' . "\n";
for ($i=0;$i < count($userData['mailAlternateAddress']); $i++) for ($i=0;$i < count($userData['mailAlternateAddress']); $i++)
{ {
$options_mailAlternateAddress .= "<option value=\"".$i."\">". $options_mailAlternateAddress .= '<option value="' . $i. '">' .
$userData['mailAlternateAddress'][$i]. $userData['mailAlternateAddress'][$i].
"</option>\n"; "</option>\n";
} }
@ -91,79 +87,82 @@
{ {
$options_mailAlternateAddress = lang('no alternate email address'); $options_mailAlternateAddress = lang('no alternate email address');
} }
$this->t->set_var("mail",$userData["mail"]);
//$this->t->set_var("mailAlternateAddress",''); could be deleted?
if ($userData["mailForwardingAddress"] == "") $this->t->set_var('mail',$userData['mail']);
//$this->t->set_var('mailAlternateAddress',''); could be deleted?
if ($userData['mailForwardingAddress'] == '')
{ {
$this->t->set_var("mailForwardingAddress",$userData["mail"]); $this->t->set_var('mailForwardingAddress',$userData['mail']);
} }
else else
{ {
$this->t->set_var("mailForwardingAddress",$userData["mailForwardingAddress"]); $this->t->set_var('mailForwardingAddress',$userData['mailForwardingAddress']);
} }
$this->t->set_var("options_mailAlternateAddress",$options_mailAlternateAddress); $this->t->set_var('options_mailAlternateAddress',$options_mailAlternateAddress);
$this->t->set_var("uid",rawurlencode($_accountData["dn"])); $this->t->set_var('uid',rawurlencode($_accountData['dn']));
if ($userData["accountStatus"] == "active") if ($userData['accountStatus'] == 'active')
$this->t->set_var("account_checked","checked"); {
if ($userData["deliveryMode"] == "forwardOnly") $this->t->set_var('account_checked','checked');
$this->t->set_var("forwardOnly_checked","checked"); }
if ($_accountData["deliverExtern"] == "active") if ($userData['deliveryMode'] == 'forwardOnly')
$this->t->set_var("deliver_checked","checked"); {
$this->t->set_var('forwardOnly_checked','checked');
}
if ($_accountData['deliverExtern'] == 'active')
{
$this->t->set_var('deliver_checked','checked');
}
} }
else else
{ {
$this->t->set_var("mail",''); $this->t->set_var('mail','');
$this->t->set_var("mailAlternateAddress",''); $this->t->set_var('mailAlternateAddress','');
$this->t->set_var("mailForwardingAddress",''); $this->t->set_var('mailForwardingAddress','');
$this->t->set_var("options_mailAlternateAddress",lang('no alternate email address')); $this->t->set_var('options_mailAlternateAddress',lang('no alternate email address'));
$this->t->set_var("account_checked",''); $this->t->set_var('account_checked','');
$this->t->set_var("forwardOnly_checked",''); $this->t->set_var('forwardOnly_checked','');
} }
// create the menu on the left, if needed // create the menu on the left, if needed
$menuClass =& CreateObject('admin.uimenuclass'); $menuClass =& CreateObject('admin.uimenuclass');
$this->t->set_var('rows',$menuClass->createHTMLCode('edit_user')); $this->t->set_var('rows',$menuClass->createHTMLCode('edit_user'));
$this->t->pparse("out","form"); $this->t->pparse('out','form');
} }
function saveUserData() function saveUserData()
{ {
global $_POST, $_GET; if($_POST['accountStatus'] == 'on')
if($_POST["accountStatus"] == "on")
{ {
$accountStatus = "active"; $accountStatus = 'active';
} }
if($_POST["forwardOnly"] == "on") if($_POST['forwardOnly'] == 'on')
{ {
$deliveryMode = "forwardOnly"; $deliveryMode = 'forwardOnly';
} }
$formData = array $formData = array
( (
'mail' => $_POST["mail"], 'mail' => $_POST['mail'],
'mailAlternateAddress' => $_POST["mailAlternateAddress"], 'mailAlternateAddress' => $_POST['mailAlternateAddress'],
'mailForwardingAddress' => $_POST["mailForwardingAddress"], 'mailForwardingAddress' => $_POST['mailForwardingAddress'],
'add_mailAlternateAddress' => $_POST["mailAlternateAddressInput"], 'add_mailAlternateAddress' => $_POST['mailAlternateAddressInput'],
'remove_mailAlternateAddress' => $_POST["mailAlternateAddress"], 'remove_mailAlternateAddress' => $_POST['mailAlternateAddress'],
'accountStatus' => $accountStatus, 'accountStatus' => $accountStatus,
'deliveryMode' => $deliveryMode 'deliveryMode' => $deliveryMode
); );
//echo "<br><br>DebugArray in uiuserdata"; //echo "<br><br>DebugArray in uiuserdata";
// echo _debug_array($formData); // echo _debug_array($formData);
if($_POST["add_mailAlternateAddress"]) $bo_action='add_mailAlternateAddress';
if($_POST["remove_mailAlternateAddress"]) $bo_action='remove_mailAlternateAddress';
if($_POST["save"]) $bo_action='save';
if (!$_POST["mail"]== "") //attribute 'mail'is not allowed to be empty if($_POST['add_mailAlternateAddress']) $bo_action='add_mailAlternateAddress';
if($_POST['remove_mailAlternateAddress']) $bo_action='remove_mailAlternateAddress';
if($_POST['save']) $bo_action='save';
if (!$_POST['mail'] == '') //attribute 'mail'is not allowed to be empty
{ {
// error generator necessary!! // error generator necessary!!
$this->boldapmgr->saveUserData($_GET['account_id'], $formData, $bo_action); $this->boldapmgr->saveUserData($_GET['account_id'], $formData, $bo_action);
@ -179,11 +178,9 @@
$this->editUserData('1'); $this->editUserData('1');
} }
} }
function translate() function translate()
{ {
$this->t->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']); $this->t->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
$this->t->set_var('lang_add',lang('add')); $this->t->set_var('lang_add',lang('add'));