Changeset 4000


Ignore:
Timestamp:
04/13/11 10:07:27 (13 years ago)
Author:
emersonfaria
Message:

Ticket #1746 - Criada autenticacao dos Backends no LDAP e corrigido bug de login alfanumerico

Location:
contrib/z-push
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • contrib/z-push/backend/BackendCalendarExpresso.php

    r3637 r4000  
    1111 * Consult LICENSE file for details 
    1212 ************************************************/ 
    13 include_once('diffbackend.php'); 
    14 include_once('include/z_RTF.php'); 
    15 include_once "include/dbconnect.php"; 
     13require_once("diffbackend.php"); 
     14require_once("include/z_RTF.php"); 
     15require_once("include/dbconnect.php"); 
     16require_once("include/authldap.php"); 
    1617 
    1718class BackendCalendarExpresso extends BackendDiff { 
    18         var $_user; 
    19         var $_devid; 
    20         var $_protocolversion; 
    2119        var $db; 
     20        var $_uidnumber; 
    2221 
    2322        function __construct() 
     
    2625 
    2726                if (!$this->db) { 
    28                         echo "A DB connect error occured.\n"; 
     27                        echo "Erro de conexao com o banco.\n"; 
    2928                        exit; 
    3029                } 
     30        } 
     31 
     32        function Logon($username, $domain, $password) { 
     33                $this->_uidnumber = $this->authUser($this->parseUser($username), $password); 
     34                if(! $this->_uidnumber) return false; 
     35                else return true; 
    3136        } 
    3237 
     
    3540                $this->_devid = $devid; 
    3641                $this->_protocolversion = $protocolversion; 
    37                 //TODO: Autenticar Usuario no LDAP 
    38  
    3942                return true; 
    4043        } 
     
    4952 
    5053        function GetMessageList($folderid, $cutoffdate) { 
    51                 $id_owner = $this->parseOwner($this->_user); 
    52                 if ($id_owner == false) return false; 
    53  
    54                 debugLog('CalendarExpresso::GetMessageList('.$id_owner.')'); 
     54                debugLog('CalendarExpresso::GetMessageList('.$this->_uidnumber.')'); 
    5555                if ($folderid != "calendar") return false; 
    5656 
     
    5959                        $result = pg_query($this->db,"BEGIN;"); 
    6060                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    61                         if ($cutoffdate == 0) $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $id_owner . "'and c.reference = 0;"); 
    62                         else $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $id_owner . "'and c.reference = 0 and c.edatetime > " . $cutoffdate . ";"); 
     61                        if ($cutoffdate == 0) $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference = 0;"); 
     62                        else $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference = 0 and c.edatetime > " . $cutoffdate . ";"); 
    6363                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    6464                        while ($row = pg_fetch_row($result)) { 
     
    8888        function GetFolderList() { 
    8989                debugLog('CalendarExpresso::GetFolderList()'); 
    90                 $calendars = array(); 
    9190                $folder = $this->StatFolder("calendar"); 
    92                 $calendars[] = $folder; 
    93                 //return $calendars; 
    9491                return $folder; 
    9592        } 
     
    327324                $message = $this->GetMessageDAO($id); 
    328325                return $message; 
    329  
    330                 //$message->?????  //phpgw_cal.priority (1 - baixa, 2 - normal, 3 - alta) //Quando for criar um registro o valor será 2. 
    331                 //$message->?????  //phpgw_cal.groups (Não vou atribuir nenhum valor) 
    332                 //$message->?????  //phpgw_cal.cal_type (quando for criar um novo registro vou inserir R para Recursivo e E para não recursivo). Quando Alterar um registro entre de Recursivo para não Recursivo e vice-versa vou fazer o mesmo da inclusão. Quando alterar entre dois tipos não recursivos, não faço nada. 
    333                 //$message->?????  //phpgw_cal.ex_participants 
    334                 //$message->?????  //phpgw_cal_user.cal_status 
    335                 //$message->?????  //phpgw_cal_user.cal_type 
    336                 //$message->?????  //phpgw_cal_repeats.recur_interval 
    337                 //$message->?????  //phpgw_cal_repeats.recur_data 
    338                 //$message->?????  //phpgw_cal_repeats.recur_exception 
    339  
    340                 //$message->timezone  //phpgw????? 
    341                 //$message->organizername //phpgw????? 
    342                 //$message->organizeremail //phpgw???? 
    343                 //$message->attendees // phpgw????  (SyncAttendee array) 
    344  
    345                 //$syncAttendee = new SyncAttendee(); 
    346                 //$syncAttendee->email  //phpgw???? 
    347                 //$syncAttendee->name   //phpgw???? 
    348326        } 
    349327 
     
    351329                debugLog('CalendarExpresso::DeleteMessage('.$folderid.', '.$id.', ..)'); 
    352330                if (!isset($id)) return false; 
    353                 $id_owner = $this->parseOwner($this->_user); 
    354                 if ($id_owner == false) return false; 
    355331                $result = pg_query($this->db, "select owner from phpgw_cal where cal_id = " . $id . ";"); 
    356332                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    357                 if ($id_owner != pg_fetch_result($result, 0, 0)) return false; 
     333                if ($this->_uidnumber != pg_fetch_result($result, 0, 0)) return false; 
    358334                try { 
    359335                        $result = pg_query($this->db,"BEGIN;"); 
     
    387363        function ChangeMessageDAO($id, $message) { 
    388364                debugLog('CalendarExpresso::ChangeMessageDAO('.$id.', ..)'); 
    389                 $id_owner = $this->parseOwner($this->_user); 
    390                 if ($id_owner == false) return false; 
    391365                try { 
    392366                        $result = pg_query($this->db,"BEGIN;"); 
     
    396370                        $found_cal_repeats = false; 
    397371                        if ($id != false) { 
    398                                 $result = pg_query($this->db, "select cal_id, cal_type, owner from phpgw_cal where cal_id = " . $id . ";"); 
     372                                $result = pg_query($this->db, "select cal_id, cal_type, owner, description from phpgw_cal where cal_id = " . $id . ";"); 
    399373                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    400374                                // tenta localizar cal_id para fazer Update 
    401375                                while ($row = pg_fetch_row($result)) { 
    402376                                        if(isset($row[0])) { 
    403                                                 if ($id_owner != $row[2]) return false; // Nao atualiza evento de outro proprietario 
     377                                                if ($this->_uidnumber != $row[2]) return false; // Nao atualiza evento de outro proprietario 
    404378                                                $cal_id = $row[0]; 
    405379                                                $cal_type_from_DB = $row[1]; 
     380                                                $description_from_DB = $row[3]; 
    406381                                                $found_cal_id = true; 
    407382                                        } 
    408383                                } 
    409384                                // Verifica se ja existe o registro do evento na tabela phpgw_cal_user 
    410                                 $result = pg_query($this->db, "select cal_id, cal_login from phpgw_cal_user where cal_id = " . $cal_id . " and cal_login = '" . $id_owner . "';"); 
     385                                $result = pg_query($this->db, "select cal_id, cal_login from phpgw_cal_user where cal_id = " . $cal_id . " and cal_login = '" . $this->_uidnumber . "';"); 
    411386                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    412387                                if ($row = pg_fetch_row($result)) { 
     
    430405                        } 
    431406                        if(isset($message->subject)) { 
    432                                 $arrayCal["title"] = $this->truncateString(utf8_decode($message->subject),80); 
     407                                $arrayCal["title"] = $this->truncateString(utf8_decode($message->subject),299); 
    433408                        } 
    434409                        if(isset($message->location)) { 
     
    454429                                if ($result_loadrtf == true) $rtf_to_ascii->parse(); 
    455430                                $arrayCal["description"] = $rtf_to_ascii->out; 
    456 //                      } else { 
    457 //                              $arrayCal["description"] = ''; 
     431                                //                      } else { 
     432                                //                              $arrayCal["description"] = ''; 
    458433                        } 
    459434                        $arrayCal["category"] = ''; 
     
    482457                                $cal_id = pg_fetch_result($result, 0, 0); 
    483458                                $arrayCal["cal_id"] = $cal_id; 
    484                                 $arrayCal["owner"] = $id_owner; 
     459                                $arrayCal["owner"] = $this->_uidnumber; 
    485460                                if (isset($message->recurrence)) $arrayCal["cal_type"] = 'M'; 
    486461                                else $arrayCal["cal_type"] = 'E'; 
     
    500475                        if (!$found_cal_user){ 
    501476                                $arrayCalUser["cal_id"] = $cal_id; 
    502                                 $arrayCalUser["cal_login"] = $id_owner; 
     477                                $arrayCalUser["cal_login"] = $this->_uidnumber; 
    503478                                //TODO: Tratar os outros valores de cal_status 
    504479                                $arrayCalUser["cal_status"] = 'A'; 
     
    506481                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    507482                        } else { 
    508                                 $result = pg_update($this->db, 'phpgw_cal_user', $arrayCalUser, array('cal_id' => $cal_id, 'cal_login' => $id_owner)); 
     483                                $result = pg_update($this->db, 'phpgw_cal_user', $arrayCalUser, array('cal_id' => $cal_id, 'cal_login' => $this->_uidnumber)); 
    509484                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    510485                        } 
     
    574549                                        else $arrayRecur["recur_enddate"] = $message->recurrence->until; 
    575550                                        date_default_timezone_set($tz); 
    576                                         /*                                      //$arrayRecur["recur_enddate"] = $message->recurrence->until - $offsetTZ; 
     551                                        /*$arrayRecur["recur_enddate"] = $message->recurrence->until - $offsetTZ; 
    577552                                         $hour = date("G", $message->starttime - (($tz["bias"] - $tz["dstbias"]) * 60)); 
    578553                                         $min = date("i", $message->starttime - (($tz["bias"] - $tz["dstbias"]) * 60)); 
     
    586561                                // Trata excecoes da recorrencia 
    587562                                if (isset($message->exceptions)){ 
    588                                         //if ($recur_exception_changed_starttimes != "") { 
    589                                         //Tem Excecoes de recorrencia do tipo Edicao 
     563                                        // Tem Excecoes de recorrencia do tipo Edicao 
    590564                                        // Verifica se ja existe o registro do evento de excecao de recorrencia na tabela phpgw_cal 
    591                                         //foreach ($array_recur_exception_changed_starttime as $except_starttime) { 
    592565                                        $recur_exception_changed_ids = ""; 
    593566                                        $recur_exception_deleted_starttimes = ""; 
     
    599572                                                        if (isset($except_cal_id)) unset($except_cal_id); 
    600573                                                        if (isset($except_cal_type_from_DB)) unset($except_cal_type_from_DB); 
     574                                                        if (isset($except_description_from_DB)) unset($except_description_from_DB); 
    601575                                                        $found_except_cal_id = false; 
    602576                                                        $found_except_cal_user = false; 
    603                                                         $result = pg_query($this->db, "select cal_id, cal_type from phpgw_cal where reference = " . $id . " and datetime = " . $recur_exception->exceptionstarttime . ";"); 
     577                                                        $result = pg_query($this->db, "select cal_id, cal_type, description from phpgw_cal where reference = " . $id . " and datetime = " . $recur_exception->exceptionstarttime . ";"); 
    604578                                                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    605579                                                        // tenta localizar cal_id para fazer Update 
     
    608582                                                                        $except_cal_id = $row[0]; 
    609583                                                                        $except_cal_type_from_DB = $row[1]; 
     584                                                                        $except_description_from_DB = $row[2]; 
    610585                                                                        $found_except_cal_id = true; 
    611586                                                                } 
     
    613588                                                        // Verifica se ja existe o registro do evento de excecao de recorrencia na tabela phpgw_cal_user 
    614589                                                        if (isset($except_cal_id)) { 
    615                                                                 $result = pg_query($this->db, "select cal_id, cal_login from phpgw_cal_user where cal_id = " . $except_cal_id . " and cal_login = '" . $id_owner . "';"); 
     590                                                                $result = pg_query($this->db, "select cal_id, cal_login from phpgw_cal_user where cal_id = " . $except_cal_id . " and cal_login = '" . $this->_uidnumber . "';"); 
    616591                                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    617592                                                                if ($row = pg_fetch_row($result)) { 
     
    627602                                                        } 
    628603                                                        if(isset($recur_exception->subject)) { 
    629                                                                 $arrayExceptCal["title"] = $this->truncateString(utf8_decode($recur_exception->subject),80); 
     604                                                                $arrayExceptCal["title"] = $this->truncateString(utf8_decode($recur_exception->subject),299); 
    630605                                                        } elseif(isset($message->subject)) { 
    631                                                                 $arrayExceptCal["title"] = $this->truncateString(utf8_decode($message->subject),80); 
     606                                                                $arrayExceptCal["title"] = $this->truncateString(utf8_decode($message->subject),299); 
    632607                                                        } 
    633608                                                        if(isset($recur_exception->location)) { 
     
    658633                                                                $arrayExceptCal["is_public"] = 1; // 1 - Normal 
    659634                                                        }else $arrayExceptCal["is_public"] = 0; // 0 - Privado 
    660                                                         if(isset($recur_exception->rtf) or isset($message->rtf)) { 
    661                                                                 $rtf_to_ascii = new rtf(); 
    662                                                                 $rtf_to_ascii->output("ascii"); 
    663                                                                 if(isset($recur_exception->rtf)) $result_loadrtf = $rtf_to_ascii->loadrtf(base64_decode($recur_exception->rtf)); 
    664                                                                 elseif(isset($message->rtf)) $result_loadrtf = $rtf_to_ascii->loadrtf(base64_decode($message->rtf)); 
    665                                                                 if ($result_loadrtf == true) $rtf_to_ascii->parse(); 
    666                                                                 $arrayExceptCal["description"] = $rtf_to_ascii->out; 
    667                                 //                      } else { 
    668                                 //                              $arrayExceptCal["description"] = ''; 
     635                                                        if (isset($recur_exception->body)) { 
     636                                                                $arrayExceptCal["description"] = utf8_decode($recur_exception->body); 
     637                                                        } elseif (!isset($except_description_from_DB)) { 
     638                                                                if (isset($message->rtf)) { 
     639                                                                        $rtf_to_ascii = new rtf(); 
     640                                                                        $rtf_to_ascii->output("ascii"); 
     641                                                                        $result_loadrtf = $rtf_to_ascii->loadrtf(base64_decode($message->rtf)); 
     642                                                                        if ($result_loadrtf == true) $rtf_to_ascii->parse(); 
     643                                                                        $arrayExceptCal["description"] = $rtf_to_ascii->out; 
     644                                                                } elseif (isset($description_from_DB)) { 
     645                                                                        $arrayExceptCal["description"] = utf8_decode($description_from_DB); 
     646                                                                } 
    669647                                                        } 
    670648                                                        $arrayExceptCal["category"] = ''; 
     
    701679                                                                $except_cal_id = pg_fetch_result($result, 0, 0); 
    702680                                                                $arrayExceptCal["cal_id"] = $except_cal_id; 
    703                                                                 $arrayExceptCal["owner"] = $id_owner; 
     681                                                                $arrayExceptCal["owner"] = $this->_uidnumber; 
    704682                                                                $arrayExceptCal["cal_type"] = 'E'; 
    705683                                                                $result = pg_insert($this->db, 'phpgw_cal', $arrayExceptCal); 
     
    714692                                                        if (!$found_except_cal_user){ 
    715693                                                                $arrayExceptCalUser["cal_id"] = $except_cal_id; 
    716                                                                 $arrayExceptCalUser["cal_login"] = $id_owner; 
     694                                                                $arrayExceptCalUser["cal_login"] = $this->_uidnumber; 
    717695                                                                //TODO: Tratar os outros valores de cal_status 
    718696                                                                $arrayExceptCalUser["cal_status"] = 'A'; 
     
    720698                                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    721699                                                        } else { 
    722                                                                 $result = pg_update($this->db, 'phpgw_cal_user', $arrayExceptCalUser, array('cal_id' => $except_cal_id, 'cal_login' => $id_owner)); 
     700                                                                $result = pg_update($this->db, 'phpgw_cal_user', $arrayExceptCalUser, array('cal_id' => $except_cal_id, 'cal_login' => $this->_uidnumber)); 
    723701                                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    724702                                                        } 
     
    805783        function addCategory($category) { 
    806784                $cat_id = false; 
    807                 $id_owner = $this->parseOwner($this->_user); 
    808                 if ($id_owner == false) return false; 
    809785                try { 
    810786                        $result = pg_query($this->db,"BEGIN;"); 
     
    813789                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    814790                        if (!($cat_id = pg_fetch_result($result, 0, 0))){ 
    815                                 $result = pg_query("SELECT cat_id from phpgw_categories WHERE cat_owner = " . $id_owner . " AND cat_appname = 'calendar' AND LOWER(to_ASCII(cat_name)) = '" . trim(strtolower($this->removeAccents(utf8_decode($category)))) . "';"); 
     791                                $result = pg_query("SELECT cat_id from phpgw_categories WHERE cat_owner = " . $this->_uidnumber . " AND cat_appname = 'calendar' AND LOWER(to_ASCII(cat_name)) = '" . trim(strtolower($this->removeAccents(utf8_decode($category)))) . "';"); 
    816792                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    817793                                if (!($cat_id = pg_fetch_result($result, 0, 0))){ 
     
    820796                                        $cat_id = pg_fetch_result($result, 0, 0); 
    821797                                        $arrayCat["cat_id"] = $cat_id; 
    822                                         $arrayCat["cat_owner"] = $id_owner; 
     798                                        $arrayCat["cat_owner"] = $this->_uidnumber; 
    823799                                        $arrayCat["cat_access"] = 'public'; 
    824800                                        $arrayCat["cat_appname"] = 'calendar'; 
     
    851827                $data = str_replace("\r", "\n", $data); 
    852828                $data = str_replace(array('\\', ';', ',', "\n"), array('\\\\', '\\;', '\\,', '\\n'), $data); 
    853                 //return u2wi($data); 
    854829                return $data; 
    855830        } 
     
    871846        } 
    872847 
    873         function parseOwner($id_owner) 
     848        function parseUser($id_user) 
    874849        { 
    875                 $pos = strripos($id_owner, '\\'); 
     850                $pos = strripos($id_user, '\\'); 
    876851                if ($pos === false) { 
    877                         if (strlen($id_owner) <= 2) return false; 
    878                         else return substr($id_owner, 0, strlen($id_owner)-2); 
     852                        if (strlen($id_user) < 1) return false; 
     853                        else return $id_user; 
    879854                } else { 
    880                         if (strlen($id_owner) <= $pos + 3) { 
     855                        if (strlen($id_user) <= $pos + 1) { 
    881856                                return false; 
    882857                        } else { 
    883                                 return substr(substr($id_owner, $pos + 1), 0, strlen(substr($id_owner, $pos + 1))-2); 
     858                                return substr(substr($id_user, $pos + 1), 0, strlen(substr($id_user, $pos + 1))); 
    884859                        } 
    885860                } 
     
    916891                return $packed; 
    917892        } 
     893 
     894        // Authenticate user and return UIDNumber attribute on success 
     895        function authUser($user, $pwd) { 
     896                $ldap = new AuthLDAP(); 
     897                $uid_number = ($ldap->bind($user,$pwd)); 
     898                $ldap->disconnect(); 
     899                unset($ldap); 
     900                if (! $uid_number) return false; 
     901                return $uid_number; 
     902        } 
    918903}; 
    919904?> 
  • contrib/z-push/backend/BackendContactsExpresso.php

    r3637 r4000  
    1111 * Consult LICENSE file for details 
    1212 ************************************************/ 
    13 include_once('diffbackend.php'); 
    14 include_once('include/z_RTF.php'); 
    15 include_once "include/dbconnect.php"; 
     13require_once("diffbackend.php"); 
     14require_once("include/z_RTF.php"); 
     15require_once("include/dbconnect.php"); 
     16require_once("include/authldap.php"); 
    1617 
    1718class BackendContactsExpresso extends BackendDiff { 
    18         var $_user; 
    19         var $_devid; 
    20         var $_protocolversion; 
    2119        var $db; 
     20        var $_uidnumber; 
    2221 
    2322        function __construct() 
     
    2625 
    2726                if (!$this->db) { 
    28                         echo "A DB connect error occured.\n"; 
     27                        echo "Erro de conexao com o Banco.\n"; 
    2928                        exit; 
    3029                } 
     30        } 
     31 
     32        function Logon($username, $domain, $password) { 
     33                $this->_uidnumber = $this->authUser($this->parseUser($username), $password); 
     34                if(! $this->_uidnumber) return false; 
     35                else return true; 
    3136        } 
    3237 
     
    3540                $this->_devid = $devid; 
    3641                $this->_protocolversion = $protocolversion; 
    37                 //TODO: Autenticar Usuario no LDAP 
    3842 
    3943                return true; 
     
    4953 
    5054        function GetMessageList($folderid, $cutoffdate) { 
    51                 $id_owner = $this->parseOwner($this->_user); 
    52                 if ($id_owner == false) return false; 
    53  
    54                 debugLog('ContactsExpresso::GetMessageList('.$id_owner.')'); 
     55                debugLog('ContactsExpresso::GetMessageList('.$this->_uidnumber.')'); 
    5556                $messages = array(); 
    5657                $ids = array(); 
     
    5859                        $result = pg_query($this->db,"BEGIN;"); 
    5960                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    60                         $result = pg_query($this->db, "select given_names, family_names, last_update, id_contact from phpgw_cc_contact where id_owner = " . $id_owner . ";"); 
     61                        $result = pg_query($this->db, "select given_names, family_names, last_update, id_contact from phpgw_cc_contact where id_owner = " . $this->_uidnumber . ";"); 
    6162                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    6263                        while ($row = pg_fetch_row($result)) { 
     
    7879        function GetFolderList() { 
    7980                debugLog('ContactsExpresso::GetFolderList()'); 
    80                 $contacts = array(); 
    8181                $folder = $this->StatFolder("root"); 
    82                 $contacts[] = $folder; 
    8382                return $folder; 
    84                 //return $contacts; 
    8583        } 
    8684 
     
    117115                debugLog('ContactsExpresso::StatMessage('.$folderid.', '.$id.')'); 
    118116                if($folderid != "root") return false; 
    119  
    120                 $id_owner = $this->parseOwner($this->_user); 
    121                 if ($id_owner == false) return false; 
    122117 
    123118                try { 
     
    149144 
    150145                // Parse the database into object 
    151                 $id_owner = $this->parseOwner($this->_user); 
    152                 if ($id_owner == false) return; 
    153  
    154146                $message = new SyncContact(); 
    155147                try { 
     
    354346                debugLog('ContactsExpresso::DeleteMessage('.$folderid.', '.$id.', ..)'); 
    355347 
    356                 $id_owner = $this->parseOwner($this->_user); 
    357                 if ($id_owner == false) return false; 
    358  
    359348                $result = pg_query($this->db,"BEGIN;"); 
    360349                try { 
     
    416405                debugLog('ContactsExpresso::ChangeMessage('.$folderid.', '.$id.', ..)'); 
    417406 
    418                 $id_owner = $this->parseOwner($this->_user); 
    419                 if ($id_owner == false) return false; 
    420407                try { 
    421408                        $result = pg_query($this->db,"BEGIN;"); 
     
    666653                        if (!$found_id_contact){ 
    667654                                $arrayContact["id_contact"] = $id_contact; 
    668                                 $arrayContact["id_owner"] = $id_owner; 
     655                                $arrayContact["id_owner"] = $this->_uidnumber; 
    669656                                $result = pg_insert($this->db, 'phpgw_cc_contact', $arrayContact); 
    670657                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
     
    10321019                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    10331020                        } 
    1034                          
     1021 
    10351022                        //TODO : Permitir mais de um número de telefone para Trabalho, Celular e Casa. O Expresso ainda não suporta isso :( 
    10361023 
     
    10681055                $data = str_replace("\r", "\n", $data); 
    10691056                $data = str_replace(array('\\', ';', ',', "\n"), array('\\\\', '\\;', '\\,', '\\n'), $data); 
    1070                 //return u2wi($data); 
    10711057                return $data; 
    10721058        } 
     
    10881074        } 
    10891075 
    1090         function parseOwner($id_owner) 
     1076        function parseUser($id_user) 
    10911077        { 
    1092                 $pos = strripos($id_owner, '\\'); 
     1078                $pos = strripos($id_user, '\\'); 
    10931079                if ($pos === false) { 
    1094                         if (strlen($id_owner) <= 2) return false; 
    1095                         else return substr($id_owner, 0, strlen($id_owner)-2); 
     1080                        if (strlen($id_user) < 1) return false; 
     1081                        else return $id_user; 
    10961082                } else { 
    1097                         if (strlen($id_owner) <= $pos + 3) { 
     1083                        if (strlen($id_user) <= $pos + 1) { 
    10981084                                return false; 
    10991085                        } else { 
    1100                                 return substr(substr($id_owner, $pos + 1), 0, strlen(substr($id_owner, $pos + 1))-2); 
     1086                                return substr(substr($id_user, $pos + 1), 0, strlen(substr($id_user, $pos + 1))); 
    11011087                        } 
    11021088                } 
     1089        } 
     1090 
     1091        // Authenticate user and return UIDNumber attribute on success 
     1092        function authUser($user, $pwd) { 
     1093                $ldap = new AuthLDAP(); 
     1094                $uid_number = ($ldap->bind($user,$pwd)); 
     1095                $ldap->disconnect(); 
     1096                unset($ldap); 
     1097                if (! $uid_number) return false; 
     1098                return $uid_number; 
    11031099        } 
    11041100}; 
  • contrib/z-push/backend/BackendProxy.php

    r3754 r4000  
    1111 * Consult LICENSE file for details 
    1212 ************************************************/ 
    13 include_once('diffbackend.php'); 
     13require_once("diffbackend.php"); 
    1414 
    1515class BackendProxy extends BackendDiff { 
     
    2828 
    2929        function Logon($username, $domain, $password) { 
    30                 global $BACKEND_EMAIL; 
    31                 if (isset($BACKEND_EMAIL)) return $this->BackendEmail->Logon($username, $domain, $password); 
    32                 else return true; 
     30                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR; 
     31                if (isset($BACKEND_EMAIL) and (! $this->BackendEmail->Logon($username, $domain, $password))) return false; 
     32                if (isset($BACKEND_CONTACTS) and (! $this->BackendContacts->Logon($username, $domain, $password))) return false; 
     33                if (isset($BACKEND_CALENDAR) and (! $this->BackendCalendar->Logon($username, $domain, $password))) return false; 
     34                return true; 
    3335        } 
    3436 
     
    4244                debugLog('BackendProxy::Setup('.$user.','.$devid.','.$protocolversion.')'); 
    4345                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR; 
    44                 $this->_user = $user; 
    45                 $this->_devid = $devid; 
    46                 $this->_protocolversion = $protocolversion; 
    4746                if (isset($BACKEND_EMAIL)) $this->BackendEmail->Setup($user, $devid, $protocolversion); 
    4847                if (isset($BACKEND_CONTACTS)) $this->BackendContacts->Setup($user, $devid, $protocolversion); 
  • contrib/z-push/config.php

    r3637 r4000  
    7979    //        'domain'    - the value of the "domain" field is used 
    8080    //        '@mydomain.com' - the username is used and the given string will be appended 
    81     define('IMAP_DEFAULTFROM', ''); 
     81    define('IMAP_DEFAULTFROM', 'domain'); 
    8282    // copy outgoing mail to this folder. If not set z-push will try the default folders 
    8383    define('IMAP_SENTFOLDER', 'INBOX/Sent'); 
     
    9595    define('VCARDDIR_DIR', '/var/www/vcf'); 
    9696 
     97    // **************************************************** 
     98    //  LDAP Authentication settings 
     99    // ****************************************************     
     100    // Set USER and PASSWORD if you are not using anonymous bind 
     101    // Must have read access to DN, UID and UIDNUMBER of all users 
     102        define("ANONYMOUS_BIND", false); 
     103        define("LDAP_BIND_USER", "cn=admin,ou=expressolivre,ou=corp,dc=empresa,dc=gov,dc=br"); 
     104        define("LDAP_BIND_PASSWORD", "senha_do_admin"); 
     105     
     106        define("LDAP_HOST", "ldap://10.200.112.132/"); // Address of your LDAP server 
     107        define("LDAP_PORT", "389"); // Port of your LDAP server 
     108 
     109        // Search base & filter 
     110        define("LDAP_SEARCH_BASE", "dc=empresa,dc=gov,dc=br"); // Base path to search the filter. Example: dc=company,dc=com 
     111        define("LDAP_SEARCH_FILTER", "uid=SEARCHVALUE"); // The filter is the user login attribute. You can change only the "uid" by other attribute. The SEARCHVALUE string is replaced by the user login inside the backends. 
     112 
     113        // LDAP field mapping. 
     114        global $ldap_field_map; 
     115        $ldap_field_map = array( 
     116                                                DN                                              => 'dn', // Change 'dn' only if you use other attribute name in your LDAP. 
     117                            UID                                         => 'uid', // Change 'uid' only if you use other attribute name in your LDAP. 
     118                        UIDNUMBER                               => 'uidnumber', // Change 'uidnumber' only if you use other attribute name in your LDAP. 
     119                     ); 
    97120?> 
Note: See TracChangeset for help on using the changeset viewer.