phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: qmailldap/inc class.boqmailldap.inc.php,1.13,1.1


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] CVS: qmailldap/inc class.boqmailldap.inc.php,1.13,1.14 class.soqmailldap.inc.php,1.13,1.14
Date: Fri, 06 Dec 2002 21:10:33 -0500

Update of /cvsroot/phpgroupware/qmailldap/inc
In directory subversions:/tmp/cvs-serv9299/inc

Modified Files:
        class.boqmailldap.inc.php class.soqmailldap.inc.php 
Log Message:
update to work with register_globals off and added ldap2 support

Index: class.boqmailldap.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/qmailldap/inc/class.boqmailldap.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** class.boqmailldap.inc.php   26 Oct 2001 14:28:55 -0000      1.13
--- class.boqmailldap.inc.php   7 Dec 2002 02:10:31 -0000       1.14
***************
*** 29,40 ****
                function boqmailldap()
                {
-                       #global $phpgw;
- 
                        $this->soqmailldap = 
CreateObject('qmailldap.soqmailldap');
-                       
                        $this->restoreSessionData();
- 
                }
!               
                function deleteServer($_serverid)
                {
--- 29,36 ----
                function boqmailldap()
                {
                        $this->soqmailldap = 
CreateObject('qmailldap.soqmailldap');
                        $this->restoreSessionData();
                }
! 
                function deleteServer($_serverid)
                {
***************
*** 44,50 ****
                function getLDAPData($_serverid, $_nocache=0)
                {
!                       global $phpgw, $HTTP_GET_VARS;
!                       
!                       if ($HTTP_GET_VARS['nocache'] == '1' || $_nocache == 
'1')
                        {
                                #print "option1<br>";
--- 40,44 ----
                function getLDAPData($_serverid, $_nocache=0)
                {
!                       if ($GLOBALS['HTTP_GET_VARS']['nocache'] == '1' || 
$_nocache == '1')
                        {
                                #print "option1<br>";
***************
*** 52,56 ****
                                $this->sessionData[$_serverid] = $LDAPData;
                                
$this->sessionData[$_serverid]['needActivation'] = 0;
!                               
                                $this->saveSessionData();
  
--- 46,50 ----
                                $this->sessionData[$_serverid] = $LDAPData;
                                
$this->sessionData[$_serverid]['needActivation'] = 0;
! 
                                $this->saveSessionData();
  
***************
*** 59,63 ****
                                #       print "... $key: $value<br>";
                                #}
!                               
                                return $this->sessionData[$_serverid];
                        }
--- 53,57 ----
                                #       print "... $key: $value<br>";
                                #}
! 
                                return $this->sessionData[$_serverid];
                        }
***************
*** 72,76 ****
                        }
                }
!               
                function getLDAPStorageData($_serverid)
                {
--- 66,70 ----
                        }
                }
! 
                function getLDAPStorageData($_serverid)
                {
***************
*** 78,82 ****
                        return $storageData;
                }
!               
                function getServerList()
                {
--- 72,76 ----
                        return $storageData;
                }
! 
                function getServerList()
                {
***************
*** 84,88 ****
                        return $serverList;
                }
!               
                function getUserData($_accountID, $_usecache)
                {
--- 78,82 ----
                        return $serverList;
                }
! 
                function getUserData($_accountID, $_usecache)
                {
***************
*** 102,110 ****
                function restoreSessionData()
                {
!                       global $phpgw;
!               
!                       $this->sessionData = 
$phpgw->session->appsession('session_data');
!                       $this->userSessionData = 
$phpgw->session->appsession('user_session_data');
!                       
                        #while(list($key, $value) = each($this->sessionData))
                        #{
--- 96,102 ----
                function restoreSessionData()
                {
!                       $this->sessionData = 
$GLOBALS['phpgw']->session->appsession('session_data');
!                       $this->userSessionData = 
$GLOBALS['phpgw']->session->appsession('user_session_data');
! 
                        #while(list($key, $value) = each($this->sessionData))
                        #{
***************
*** 117,121 ****
                {
                        $serverid = $_getVars['serverid'];
!                       
                        if (isset($_postVars["bo_action"]))
                        {
--- 109,113 ----
                {
                        $serverid = $_getVars['serverid'];
! 
                        if (isset($_postVars["bo_action"]))
                        {
***************
*** 130,157 ****
                                return false;
                        }
!                       
                        #print "bo_action: $bo_action<br>";
!                       
                        switch ($bo_action)
                        {
!                               case "add_locals":
                                        $count = 
count($this->sessionData[$serverid]['locals']);
!                                       
                                        
$this->sessionData[$serverid]['locals'][$count] = 
!                                               $_postVars["new_local"];
!                                               
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
-                                       
                                        $this->saveSessionData();
-                                       
                                        break;
!                                       
!                               case "add_rcpthosts":
                                        $count = 
count($this->sessionData[$serverid]['rcpthosts']);
!                                       
!                                       
$this->sessionData[$serverid]['rcpthosts'][$count] = 
!                                               $_postVars["new_rcpthost"];
!                                               
!                                       if ($_postVars["add_to_local"] == "on")
                                        {
                                                $count = 
count($this->sessionData[$serverid]['locals']);
--- 122,143 ----
                                return false;
                        }
! 
                        #print "bo_action: $bo_action<br>";
! 
                        switch ($bo_action)
                        {
!                               case 'add_locals':
                                        $count = 
count($this->sessionData[$serverid]['locals']);
! 
                                        
$this->sessionData[$serverid]['locals'][$count] = 
!                                               $_postVars['new_local'];
! 
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
                                        $this->saveSessionData();
                                        break;
!                               case 'add_rcpthosts':
                                        $count = 
count($this->sessionData[$serverid]['rcpthosts']);
!                                       
$this->sessionData[$serverid]['rcpthosts'][$count] = $_postVars['new_rcpthost'];
!                                       if ($_postVars['add_to_local'] == 'on')
                                        {
                                                $count = 
count($this->sessionData[$serverid]['locals']);
***************
*** 160,193 ****
                                                        
$_postVars["new_rcpthost"];
                                        }
-                                       
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
-                                       
                                        $this->saveSessionData();
-                                       
                                        break;
!                                       
!                               case "add_smtproute":
                                        $count = 
count($this->sessionData[$serverid]['smtproutes']);
!                               
!                                       
$this->sessionData[$serverid]['smtproutes'][$count] =
!                                               sprintf("%s:%s:%s",
!                                                       
$_postVars["domain_name"],
!                                                       
$_postVars["remote_server"],
!                                                       
$_postVars["remote_port"]
!                                               );
!                               
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
-                                       
                                        $this->saveSessionData();
-                                       
                                        break;
!                                       
!                               case "remove_locals":
                                        $i=0;
-                                       
                                        while(list($key, $value) = 
each($this->sessionData[$serverid]['locals']))
                                        {
                                                #print ".. $key: $value<br>";
!                                               if ($key != 
$_postVars["locals"])
                                                {
                                                        $newLocals[$i]=$value;
--- 146,167 ----
                                                        
$_postVars["new_rcpthost"];
                                        }
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
                                        $this->saveSessionData();
                                        break;
!                               case 'add_smtproute':
                                        $count = 
count($this->sessionData[$serverid]['smtproutes']);
!                                       
$this->sessionData[$serverid]['smtproutes'][$count] = sprintf("%s:%s:%s",
!                                                                               
                                                                        
$_postVars['domain_name'],
!                                                                               
                                                                        
$_postVars['remote_server'],
!                                                                               
                                                                        
$_postVars['remote_port']);
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
                                        $this->saveSessionData();
                                        break;
!                               case 'remove_locals':
                                        $i=0;
                                        while(list($key, $value) = 
each($this->sessionData[$serverid]['locals']))
                                        {
                                                #print ".. $key: $value<br>";
!                                               if ($key != 
$_postVars['locals'])
                                                {
                                                        $newLocals[$i]=$value;
***************
*** 197,214 ****
                                        }
                                        $this->sessionData[$serverid]['locals'] 
= $newLocals;
-                                       
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
-                                       
                                        $this->saveSessionData();
-                                       
                                        break;
!                                       
!                               case "remove_rcpthosts":
                                        $i=0;
-                                       
                                        while(list($key, $value) = 
each($this->sessionData[$serverid]['rcpthosts']))
                                        {
                                                #print ".. $key: $value<br>";
!                                               if ($key != 
$_postVars["rcpthosts"])
                                                {
                                                        
$newRcpthosts[$i]=$value;
--- 171,183 ----
                                        }
                                        $this->sessionData[$serverid]['locals'] 
= $newLocals;
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
                                        $this->saveSessionData();
                                        break;
!                               case 'remove_rcpthosts':
                                        $i=0;
                                        while(list($key, $value) = 
each($this->sessionData[$serverid]['rcpthosts']))
                                        {
                                                #print ".. $key: $value<br>";
!                                               if ($key != 
$_postVars['rcpthosts'])
                                                {
                                                        
$newRcpthosts[$i]=$value;
***************
*** 218,235 ****
                                        }
                                        
$this->sessionData[$serverid]['rcpthosts'] = $newRcpthosts;
-                                       
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
-                                       
                                        $this->saveSessionData();
-                                       
                                        break;
!                                       
!                               case "remove_smtproute":
                                        $i=0;
-                                       
                                        while(list($key, $value) = 
each($this->sessionData[$serverid]['smtproutes']))
                                        {
                                                #print ".. $key: $value : 
".$_getVars["smtproute_id"]."<br>";
!                                               if ($key != 
$_getVars["smtproute_id"])
                                                {
                                                        
$newSmtproutes[$i]=$value;
--- 187,199 ----
                                        }
                                        
$this->sessionData[$serverid]['rcpthosts'] = $newRcpthosts;
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
                                        $this->saveSessionData();
                                        break;
!                               case 'remove_smtproute':
                                        $i=0;
                                        while(list($key, $value) = 
each($this->sessionData[$serverid]['smtproutes']))
                                        {
                                                #print ".. $key: $value : 
".$_getVars["smtproute_id"]."<br>";
!                                               if ($key != 
$_getVars['smtproute_id'])
                                                {
                                                        
$newSmtproutes[$i]=$value;
***************
*** 239,298 ****
                                        }
                                        
$this->sessionData[$serverid]['smtproutes'] = $newSmtproutes;
-                               
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
-                                       
                                        $this->saveSessionData();
-                                       
                                        break;
!                               case "save_ldap":
                                        #print "hallo".$_getVars["serverid"]." 
".$_postVars["servername"]."<br>";
                                        $data = array
                                        (
!                                               "qmail_servername"      => 
$_postVars["qmail_servername"],
!                                               "description"           => 
$_postVars["description"],
!                                               "ldap_basedn"           => 
$_postVars["ldap_basedn"],
!                                               "id"                    => 
$_getVars["serverid"]
                                        );
!                                       if (!isset($_getVars["serverid"]))
                                        {
!                                               
$this->soqmailldap->update("add_server",$data);
                                        }
                                        else
                                        {
!                                               
$this->soqmailldap->update("update_server",$data);
                                        }
! 
!                                       
$this->getLDAPData($_getVars["serverid"], '1');
!                                       
                                        break;
!                                       
!                               case "write_to_ldap":
!                               
                                        
$this->soqmailldap->writeConfigData($this->sessionData[$serverid], $serverid);
-                               
                                        
$this->sessionData[$serverid]['needActivation'] = 0;
-                               
                                        $this->saveSessionData();
-                                       
                                        break;
                        }
                }
!               
                function saveSessionData()
                {
!                       global $phpgw;
!                       
!                       
$phpgw->session->appsession('session_data','',$this->sessionData);
!                       
$phpgw->session->appsession('user_session_data','',$this->userSessionData);
                }
!               
                function saveUserData($_accountID, $_formData, $_boAction)
                {
!                       $this->userSessionData[$_accountID]['mailLocalAddress'] 
        = $_formData["mailLocalAddress"];
!                       $this->userSessionData[$_accountID]['accountStatus']    
        = $_formData["accountStatus"];
!                       
$this->userSessionData[$_accountID]['mailRoutingAddress']       = 
$_formData["mailRoutingAddress"];
!                       $this->userSessionData[$_accountID]['qmailDotMode']     
        = $_formData["qmailDotMode"];
!                       
$this->userSessionData[$_accountID]['deliveryProgramPath']      = 
$_formData["deliveryProgramPath"];
!                       
                        switch ($_boAction)
                        {
--- 203,250 ----
                                        }
                                        
$this->sessionData[$serverid]['smtproutes'] = $newSmtproutes;
                                        
$this->sessionData[$serverid]['needActivation'] = 1;
                                        $this->saveSessionData();
                                        break;
!                               case 'save_ldap':
                                        #print "hallo".$_getVars["serverid"]." 
".$_postVars["servername"]."<br>";
                                        $data = array
                                        (
!                                               'qmail_servername'      => 
$_postVars['qmail_servername'],
!                                               'description'           => 
$_postVars['description'],
!                                               'ldap_basedn'           => 
$_postVars['ldap_basedn'],
!                                               'id'                            
=> $_getVars['serverid']
                                        );
!                                       if (!isset($_getVars['serverid']))
                                        {
!                                               
$this->soqmailldap->update('add_server',$data);
                                        }
                                        else
                                        {
!                                               
$this->soqmailldap->update('update_server',$data);
                                        }
!                                       
$this->getLDAPData($_getVars['serverid'], '1');
                                        break;
!                               case 'write_to_ldap':
                                        
$this->soqmailldap->writeConfigData($this->sessionData[$serverid], $serverid);
                                        
$this->sessionData[$serverid]['needActivation'] = 0;
                                        $this->saveSessionData();
                                        break;
                        }
                }
! 
                function saveSessionData()
                {
!                       
$GLOBALS['phpgw']->session->appsession('session_data','',$this->sessionData);
!                       
$GLOBALS['phpgw']->session->appsession('user_session_data','',$this->userSessionData);
                }
! 
                function saveUserData($_accountID, $_formData, $_boAction)
                {
!                       $this->userSessionData[$_accountID]['mailLocalAddress'] 
        = $_formData['mailLocalAddress'];
!                       $this->userSessionData[$_accountID]['accountStatus']    
        = $_formData['accountStatus'];
!                       
$this->userSessionData[$_accountID]['mailRoutingAddress']       = 
$_formData['mailRoutingAddress'];
!                       $this->userSessionData[$_accountID]['qmailDotMode']     
        = $_formData['qmailDotMode'];
!                       
$this->userSessionData[$_accountID]['deliveryProgramPath']      = 
$_formData['deliveryProgramPath'];
! 
                        switch ($_boAction)
                        {
***************
*** 307,321 ****
                                                
$this->userSessionData[$_accountID]['mailAlternateAddress'] = array();
                                        }
-                                       
                                        
$this->userSessionData[$_accountID]['mailAlternateAddress'][$count] = 
                                                
$_formData['add_mailAlternateAddress'];
                                                
                                        $this->saveSessionData();
-                                       
                                        break;
-                                       
                                case 'remove_mailAlternateAddress':
                                        $i=0;
-                                       
                                        while(list($key, $value) = 
each($this->userSessionData[$_accountID]['mailAlternateAddress']))
                                        {
--- 259,269 ----
***************
*** 329,340 ****
                                        }
                                        
$this->userSessionData[$_accountID]['mailAlternateAddress'] = 
$newMailAlternateAddress;
-                                       
                                        $this->saveSessionData();
- 
                                        break;
-                                       
                                case 'save':
                                        
$this->soqmailldap->saveUserData($_accountID, 
$this->userSessionData[$_accountID]);
-                                       
                                        break;
                        }
--- 277,284 ----

Index: class.soqmailldap.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/qmailldap/inc/class.soqmailldap.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** class.soqmailldap.inc.php   26 Oct 2001 14:28:55 -0000      1.13
--- class.soqmailldap.inc.php   7 Dec 2002 02:10:31 -0000       1.14
***************
*** 1,7 ****
  <?php
        
/***************************************************************************\
!       * phpGroupWare - Notes                                                  
    *
        * http://www.phpgroupware.org                                           
    *
!       * Written by : Bettina Gille address@hidden                         *
        * -------------------------------------------------                     
    *
        * This program is free software; you can redistribute it and/or modify 
it   *
--- 1,7 ----
  <?php
        
/***************************************************************************\
!       * phpGroupWare - QMailLDAP                                              
    *
        * http://www.phpgroupware.org                                           
    *
!       * Written by : Lars Kneschke address@hidden                           *
        * -------------------------------------------------                     
    *
        * This program is free software; you can redistribute it and/or modify 
it   *
***************
*** 16,24 ****
                function soqmailldap()
                {
!                       global $phpgw, $phpgw_info;
  
!                       $this->db               = $phpgw->db;
                }
!               
                function deleteServer($_serverid)
                {
--- 16,38 ----
                function soqmailldap()
                {
!                       $this->db                       = $GLOBALS['phpgw']->db;
!                       $this->ldap                     = 
$GLOBALS['phpgw']->common->ldapConnect();
  
!                       /*$this->config         = 
CreateObject('phpgwapi.config','phpgwapi');
!                       $this->config->read_repository();*/
!                       $ldap_version   = 
$GLOBALS['phpgw_info']['server']['ldap_version'];
! 
!                       if ($ldap_version == 3)
!                       {
!                               $this->mail_address             = 'mail';
!                               $this->routing_address  = 'mailRoutingAddress';
!                       }
!                       else
!                       {
!                               $this->mail_address             = 
'maillocaladdress';
!                               $this->routing_address  = 
'mailForwardingAddress';
!                       }
                }
! 
                function deleteServer($_serverid)
                {
***************
*** 42,46 ****
                        else
                        {
!                               return false;
                        }
                }
--- 56,60 ----
                        else
                        {
!                               return False;
                        }
                }
***************
*** 48,59 ****
                function getLDAPData($_serverid)
                {
-                       global $phpgw;
-               
                        $storageData = $this->getLDAPStorageData($_serverid);
!                       
!                       $ldap = $phpgw->common->ldapConnect();
                        $filter = "cn=".$storageData['qmail_servername'];
!                       
!                       $sri = 
@ldap_read($ldap,$storageData['ldap_basedn'],$filter);
                        if ($sri)
                        {
--- 62,70 ----
                function getLDAPData($_serverid)
                {
                        $storageData = $this->getLDAPStorageData($_serverid);
! 
                        $filter = "cn=".$storageData['qmail_servername'];
! 
!                       $sri = 
@ldap_read($this->ldap,$storageData['ldap_basedn'],$filter);
                        if ($sri)
                        {
***************
*** 63,71 ****
                                unset($allValues[0]['locals']['count']);
                                unset($allValues[0]['smtproutes']['count']);
!                               
                                $data = array
                                (
!                                       'rcpthosts'     => 
$allValues[0]['rcpthosts'],
!                                       'locals'        => 
$allValues[0]['locals'],
                                        'smtproutes'    => 
$allValues[0]['smtproutes'],
                                        'ldapbasedn'    => 
$allValues[0]['ldapbasedn'][0]
--- 74,82 ----
                                unset($allValues[0]['locals']['count']);
                                unset($allValues[0]['smtproutes']['count']);
! 
                                $data = array
                                (
!                                       'rcpthosts'             => 
$allValues[0]['rcpthosts'],
!                                       'locals'                => 
$allValues[0]['locals'],
                                        'smtproutes'    => 
$allValues[0]['smtproutes'],
                                        'ldapbasedn'    => 
$allValues[0]['ldapbasedn'][0]
***************
*** 102,124 ****
                        else
                        {
!                               return false;
                        }
-                       
                }
!               
                function getServerList()
                {
                        $query = "select id,qmail_servername,description from 
phpgw_qmailldap";
                        $this->db->query($query);
!                       
                        $i=0;
                        while ($this->db->next_record())
                        {
!                               $serverList[$i]['id']                   = 
$this->db->f('id');
                                $serverList[$i]['qmail_servername']     = 
$this->db->f('qmail_servername');
                                $serverList[$i]['description']          = 
$this->db->f('description');
                                $i++;
                        }
!                       
                        if ($i>0)
                        {
--- 113,134 ----
                        else
                        {
!                               return False;
                        }
                }
! 
                function getServerList()
                {
                        $query = "select id,qmail_servername,description from 
phpgw_qmailldap";
                        $this->db->query($query);
! 
                        $i=0;
                        while ($this->db->next_record())
                        {
!                               $serverList[$i]['id']                           
= $this->db->f('id');
                                $serverList[$i]['qmail_servername']     = 
$this->db->f('qmail_servername');
                                $serverList[$i]['description']          = 
$this->db->f('description');
                                $i++;
                        }
! 
                        if ($i>0)
                        {
***************
*** 127,131 ****
                        else
                        {
!                               return false;
                        }
                }
--- 137,141 ----
                        else
                        {
!                               return False;
                        }
                }
***************
*** 133,142 ****
                function getUserData($_accountID)
                {
-                       global $phpgw, $phpgw_info;
- 
-                       $ldap = $phpgw->common->ldapConnect();
                        $filter = "(&(uidnumber=$_accountID))";
!                       
!                       $sri = 
@ldap_search($ldap,$phpgw_info['server']['ldap_context'],$filter);
                        if ($sri)
                        {
--- 143,152 ----
                function getUserData($_accountID)
                {
                        $filter = "(&(uidnumber=$_accountID))";
! 
!                       $mail_address           = $this->mail_address;
!                       $routing_address        = $this->routing_address;
! 
!                       $sri = 
@ldap_search($this->ldap,$GLOBALS['phpgw_info']['server']['ldap_context'],$filter);
                        if ($sri)
                        {
***************
*** 145,178 ****
                                {
                                        #print "found something<br>";
!                                       $userData["mailLocalAddress"]           
= $allValues[0]["maillocaladdress"][0];
!                                       $userData["mailAlternateAddress"]       
= $allValues[0]["mailalternateaddress"];
!                                       $userData["accountStatus"]              
= $allValues[0]["accountstatus"][0];
!                                       $userData["mailRoutingAddress"]         
= $allValues[0]["mailroutingaddress"][0];
!                                       $userData["qmailDotMode"]               
= $allValues[0]["qmaildotmode"][0];
!                                       $userData["deliveryProgramPath"]        
= $allValues[0]["deliveryprogrampath"][0];
!                                       if 
($userData["mailAlternateAddress"]["count"] == 0)
                                        {
!                                               
$userData["mailAlternateAddress"]='';
                                        }
                                        else
                                        {
!                                               
unset($userData["mailAlternateAddress"]["count"]);
                                        }
                                        return $userData;
                                }
                        }
!                       
                        // if we did not return before, return false
!                       return false;
                }
                
                function saveUserData($_accountID, $_accountData)
                {
-                       global $phpgw, $phpgw_info;
-                       
-                       $ldap = $phpgw->common->ldapConnect();
                        $filter = "uidnumber=$_accountID";
!                       
!                       $sri = 
@ldap_search($ldap,$phpgw_info['server']['ldap_context'],$filter);
                        if ($sri)
                        {
--- 155,186 ----
                                {
                                        #print "found something<br>";
!                                       $userData['mailLocalAddress']           
= $allValues[0][$mail_address][0];
!                                       $userData['accountStatus']              
        = $allValues[0]['accountstatus'][0];
!                                       $userData['mailForwardingAddress']      
= $allValues[0][$routing_address][0];
!                                       $userData['qmailDotMode']               
        = $allValues[0]['qmaildotmode'][0];
!                                       $userData['deliveryProgramPath']        
= $allValues[0]['deliveryprogrampath'][0];
!                                       $userData['mailAlternateAddress']       
= $allValues[0]['mailalternateaddress'];
! 
!                                       if 
($userData['mailAlternateAddress']['count'] == 0)
                                        {
!                                               
$userData['mailAlternateAddress']='';
                                        }
                                        else
                                        {
!                                               
unset($userData['mailAlternateAddress']['count']);
                                        }
                                        return $userData;
                                }
                        }
! 
                        // if we did not return before, return false
!                       return False;
                }
                
                function saveUserData($_accountID, $_accountData)
                {
                        $filter = "uidnumber=$_accountID";
! 
!                       $sri = 
@ldap_search($this->ldap,$GLOBALS['phpgw_info']['server']['ldap_context'],$filter);
                        if ($sri)
                        {
***************
*** 180,214 ****
                                $accountDN      = $allValues[0]['dn'];
                                $uid            = $allValues[0]['uid'][0];
!                               $homedirectory  = 
$allValues[0]['homedirectory'][0];
                        }
                        else
                        {
!                               return false;
                        }
!                       
                        if(empty($homedirectory))
                        {
!                               $homedirectory = "/home/".$uid;
                        }
!                       
                        $newData = array 
                        (
!                               'mailLocalAddress'      => 
$_accountData["mailLocalAddress"],
!                               'mailAlternateAddress'  => 
$_accountData["mailAlternateAddress"],
!                               'mailRoutingAddress'    => 
$_accountData["mailRoutingAddress"],
!                               'homedirectory'         => $homedirectory,
!                               'mailMessageStore'      => 
$homedirectory."/Maildir/",
!                               'gidnumber'             => '1000',
!                               'qmailDotMode'          => 
$_accountData["qmailDotMode"],
!                               'deliveryProgramPath'   => 
$_accountData["deliveryProgramPath"],
!                               'accountStatus'         => 
$_accountData["accountStatus"]
                        );
!                       ldap_mod_replace ($ldap, $accountDN, $newData);
!                       
!                       $newData = array
!                       (
!                               'objectclass'   => "qmailUser"
!                       );
!                       @ldap_mod_add($ldap, $accountDN, $newData);
                        #print ldap_error($ldap);
                }
--- 188,243 ----
                                $accountDN      = $allValues[0]['dn'];
                                $uid            = $allValues[0]['uid'][0];
!                               $homedirectory  = 
(isset($allValues[0]['homedirectory'][0])?$allValues[0]['homedirectory'][0]:'/home/'
 . $uid);
                        }
                        else
                        {
!                               return False;
                        }
! 
!                       $mail_address           = $this->mail_address;
!                       $routing_address        = $this->routing_address;
! 
!                       $newData = array
!                       (
!                               $mail_address   => 
$_accountData['mailLocalAddress'],
!                               'objectclass'   => 'qmailUser'
!                       );
!                       @ldap_mod_add($this->ldap, $accountDN, $newData);
! 
                        if(empty($homedirectory))
                        {
!                               $homedirectory = '/home/' . $uid;
                        }
! 
                        $newData = array 
                        (
!                               $mail_address                   => 
(isset($_accountData['mailLocalAddress'])?$_accountData['mailLocalAddress']:$uid
 . '@localhost'),
!                               'homedirectory'                 => 
$homedirectory,
!                               'mailMessageStore'              => 
$homedirectory . '/Maildir/',
!                               'qmailDotMode'                  => 
(isset($_accountData['qmailDotMode'])?$_accountData['qmailDotMode']:'ldaponly')
                        );
! 
!                       if ($_accountData['accountStatus'])
!                       {
!                               $newData['accountStatus'] = 
$_accountData['accountStatus'];
!                       }
! 
!                       if ($_accountData['mailAlternateAddress'])
!                       {
!                               $newData['mailAlternateAddress'] = 
$_accountData['mailAlternateAddress'];
!                       }
! 
!                       if ($_accountData['mailForwardingAddress'])
!                       {
!                               $newData[$routing_address] = 
$_accountData['mailForwardingAddress'];
!                       }
! 
!                       if ($_accountData['deliveryProgramPath'])
!                       {
!                               $newData['deliveryProgramPath'] = 
$_accountData['deliveryProgramPath'];
!                       }
! 
!                       ldap_mod_replace ($this->ldap, $accountDN, $newData);
! 
                        #print ldap_error($ldap);
                }
***************
*** 218,239 ****
                        switch ($_action)
                        {
!                               case "add_server":
!                                       $query = sprintf("insert into 
phpgw_qmailldap (description, ldap_basedn, qmail_servername)
!                                                       values 
('%s','%s','%s')",
                                                        $_data['description'],
                                                        $_data['ldap_basedn'],
!                                                       
$_data["qmail_servername"]);
                                        $this->db->query($query);
                                        break;
!                                       
!                               case "update_server":
!                                       $query = sprintf("update 
phpgw_qmailldap set 
!                                                         description='%s',
!                                                         ldap_basedn='%s',
!                                                         qmail_servername='%s' 
where id='%s'",
                                                $_data['description'],
                                                $_data['ldap_basedn'],
!                                               $_data["qmail_servername"],
!                                               $_data["id"]);
                                        $this->db->query($query);
                                        break;
--- 247,263 ----
                        switch ($_action)
                        {
!                               case 'add_server':
!                                       $query = sprintf("insert into 
phpgw_qmailldap (description, ldap_basedn, qmail_servername) values 
('%s','%s','%s')",
                                                        $_data['description'],
                                                        $_data['ldap_basedn'],
!                                                       
$_data['qmail_servername']);
                                        $this->db->query($query);
                                        break;
!                               case 'update_server':
!                                       $query = sprintf("update 
phpgw_qmailldap set description='%s',ldap_basedn='%s',qmail_servername='%s' 
where id='%s'",
                                                $_data['description'],
                                                $_data['ldap_basedn'],
!                                               $_data['qmail_servername'],
!                                               $_data['id']);
                                        $this->db->query($query);
                                        break;
***************
*** 243,269 ****
                function writeConfigData($_data, $_serverid)
                {
-                       global $phpgw;
-               
                        $storageData = $this->getLDAPStorageData($_serverid);
                        
                        #print "write Data for 
".$storageData['qmail_servername']."<br>";
                        
-                       $ds = $phpgw->common->ldapConnect();
-                       
                        // check if the DN exists, if not create it
                        $filter = "objectclass=*";
!                       @ldap_read($ds,$storageData['ldap_basedn'], $filter);
                        if (ldap_errno($ds) == 32)
                        {
!                               $ldapData["objectclass"][0]     = 
"qmailcontrol";
!                               $ldapData["cn"]                 = 
$storageData['qmail_servername'];
                                
ldap_add($ds,$storageData['ldap_basedn'],$ldapData);
                        }
!                       
!                       $ldapData['rcpthosts']          = $_data['rcpthosts'];
                        $ldapData['locals']             = $_data['locals'];
!                       $ldapData['smtproutes']         = $_data['smtproutes'];
!                       
!                       ldap_modify($ds,$storageData['ldap_basedn'],$ldapData);
                }
        }
--- 267,289 ----
                function writeConfigData($_data, $_serverid)
                {
                        $storageData = $this->getLDAPStorageData($_serverid);
                        
                        #print "write Data for 
".$storageData['qmail_servername']."<br>";
                        
                        // check if the DN exists, if not create it
                        $filter = "objectclass=*";
!                       @ldap_read($this->ldap,$storageData['ldap_basedn'], 
$filter);
                        if (ldap_errno($ds) == 32)
                        {
!                               $ldapData['objectclass'][0]     = 
'qmailcontrol';
!                               $ldapData['cn']                         = 
$storageData['qmail_servername'];
                                
ldap_add($ds,$storageData['ldap_basedn'],$ldapData);
                        }
! 
!                       $ldapData['rcpthosts']  = $_data['rcpthosts'];
                        $ldapData['locals']             = $_data['locals'];
!                       $ldapData['smtproutes'] = $_data['smtproutes'];
! 
!                       
ldap_modify($this->ldap,$storageData['ldap_basedn'],$ldapData);
                }
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]