Changeset 4000 for contrib/z-push/backend/BackendContactsExpresso.php
- Timestamp:
- 04/13/11 10:07:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/z-push/backend/BackendContactsExpresso.php
r3637 r4000 11 11 * Consult LICENSE file for details 12 12 ************************************************/ 13 include_once('diffbackend.php'); 14 include_once('include/z_RTF.php'); 15 include_once "include/dbconnect.php"; 13 require_once("diffbackend.php"); 14 require_once("include/z_RTF.php"); 15 require_once("include/dbconnect.php"); 16 require_once("include/authldap.php"); 16 17 17 18 class BackendContactsExpresso extends BackendDiff { 18 var $_user;19 var $_devid;20 var $_protocolversion;21 19 var $db; 20 var $_uidnumber; 22 21 23 22 function __construct() … … 26 25 27 26 if (!$this->db) { 28 echo " A DB connect error occured.\n";27 echo "Erro de conexao com o Banco.\n"; 29 28 exit; 30 29 } 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; 31 36 } 32 37 … … 35 40 $this->_devid = $devid; 36 41 $this->_protocolversion = $protocolversion; 37 //TODO: Autenticar Usuario no LDAP38 42 39 43 return true; … … 49 53 50 54 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.')'); 55 56 $messages = array(); 56 57 $ids = array(); … … 58 59 $result = pg_query($this->db,"BEGIN;"); 59 60 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 . ";"); 61 62 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 62 63 while ($row = pg_fetch_row($result)) { … … 78 79 function GetFolderList() { 79 80 debugLog('ContactsExpresso::GetFolderList()'); 80 $contacts = array();81 81 $folder = $this->StatFolder("root"); 82 $contacts[] = $folder;83 82 return $folder; 84 //return $contacts;85 83 } 86 84 … … 117 115 debugLog('ContactsExpresso::StatMessage('.$folderid.', '.$id.')'); 118 116 if($folderid != "root") return false; 119 120 $id_owner = $this->parseOwner($this->_user);121 if ($id_owner == false) return false;122 117 123 118 try { … … 149 144 150 145 // Parse the database into object 151 $id_owner = $this->parseOwner($this->_user);152 if ($id_owner == false) return;153 154 146 $message = new SyncContact(); 155 147 try { … … 354 346 debugLog('ContactsExpresso::DeleteMessage('.$folderid.', '.$id.', ..)'); 355 347 356 $id_owner = $this->parseOwner($this->_user);357 if ($id_owner == false) return false;358 359 348 $result = pg_query($this->db,"BEGIN;"); 360 349 try { … … 416 405 debugLog('ContactsExpresso::ChangeMessage('.$folderid.', '.$id.', ..)'); 417 406 418 $id_owner = $this->parseOwner($this->_user);419 if ($id_owner == false) return false;420 407 try { 421 408 $result = pg_query($this->db,"BEGIN;"); … … 666 653 if (!$found_id_contact){ 667 654 $arrayContact["id_contact"] = $id_contact; 668 $arrayContact["id_owner"] = $ id_owner;655 $arrayContact["id_owner"] = $this->_uidnumber; 669 656 $result = pg_insert($this->db, 'phpgw_cc_contact', $arrayContact); 670 657 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); … … 1032 1019 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 1033 1020 } 1034 1021 1035 1022 //TODO : Permitir mais de um número de telefone para Trabalho, Celular e Casa. O Expresso ainda não suporta isso :( 1036 1023 … … 1068 1055 $data = str_replace("\r", "\n", $data); 1069 1056 $data = str_replace(array('\\', ';', ',', "\n"), array('\\\\', '\\;', '\\,', '\\n'), $data); 1070 //return u2wi($data);1071 1057 return $data; 1072 1058 } … … 1088 1074 } 1089 1075 1090 function parse Owner($id_owner)1076 function parseUser($id_user) 1091 1077 { 1092 $pos = strripos($id_ owner, '\\');1078 $pos = strripos($id_user, '\\'); 1093 1079 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; 1096 1082 } else { 1097 if (strlen($id_ owner) <= $pos + 3) {1083 if (strlen($id_user) <= $pos + 1) { 1098 1084 return false; 1099 1085 } 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))); 1101 1087 } 1102 1088 } 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; 1103 1099 } 1104 1100 };
Note: See TracChangeset
for help on using the changeset viewer.