[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - LDAP wrapper class for contacts * 4 * http://www.egroupware.org * 5 * Written by Cornelius Weiss <egw@von-und-zu-weiss.de> * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \**************************************************************************/ 12 13 /* $Id: class.so_ldap.inc.php 20295 2006-02-15 12:31:25Z $ */ 14 15 require_once (EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.contacts.inc.php'); 16 17 /** 18 * Wrapper class for phpgwapi.contacts_ldap 19 * This makes it compatible with vars and parameters of so_sql 20 * Maybe one day this becomes a generalized ldap storage object :-) 21 * 22 * @package addressbook 23 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License 24 */ 25 class so_ldap extends contacts 26 { 27 var $data; 28 var $db_data_cols; 29 var $db_key_cols; 30 31 /** 32 * constructor of the class 33 * 34 */ 35 function so_ldap() 36 { 37 parent::contacts(); 38 $this->db_data_cols = $this->stock_contact_fields + $this->non_contact_fields; 39 } 40 41 /** 42 * reads row matched by key and puts all cols in the data array 43 * 44 * @param array $keys array with keys in form internalName => value, may be a scalar value if only one key 45 * @param string/array $extra_cols string or array of strings to be added to the SELECT, eg. "count(*) as num" 46 * @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or 47 * @return array/boolean data if row could be retrived else False 48 */ 49 function read($keys,$extra_cols='',$join='') 50 { 51 $contacts = parent::read_single_entry($keys); 52 return $contacts[0]; 53 } 54 55 /** 56 * saves the content of data to the db 57 * 58 * @param array $keys if given $keys are copied to data before saveing => allows a save as 59 * @return int 0 on success and errno != 0 else 60 */ 61 function save($keys=null) 62 { 63 $data =& $this->data; 64 65 // new contact 66 if(empty($this->data[$this->contacts_id])) 67 { 68 $ret = parent::add($data['owner'],$data,$data['access'],$data['cat_id'],$data['tid']); 69 } 70 else 71 { 72 $ret = parent::update($data[$this->contacts_id],$data['owner'],$data); 73 } 74 return $ret === false ? 1 : 0; 75 } 76 77 /** 78 * deletes row representing keys in internal data or the supplied $keys if != null 79 * 80 * @param array $keys if given array with col => value pairs to characterise the rows to delete 81 * @return int affected rows, should be 1 if ok, 0 if an error 82 */ 83 function delete($keys=null) 84 { 85 // single entry 86 if($keys[$this->contacts_id]) $keys = array( 0 => $keys); 87 88 $ret = 0; 89 foreach($keys as $entry) 90 { 91 if(parent::delete($entry[$this->contacts_id]) === false) 92 { 93 return 0; 94 } 95 else 96 { 97 $ret++; 98 } 99 } 100 return $ret; 101 } 102 103 /** 104 * searches db for rows matching searchcriteria 105 * 106 * '*' and '?' are replaced with sql-wildcards '%' and '_' 107 * 108 * @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) 109 * @param boolean/string $only_keys=true True returns only keys, False returns all cols. comma seperated list of keys to return 110 * @param string $order_by='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) 111 * @param string/array $extra_cols='' string or array of strings to be added to the SELECT, eg. "count(*) as num" 112 * @param string $wildcard='' appended befor and after each criteria 113 * @param boolean $empty=false False=empty criteria are ignored in query, True=empty have to be empty in row 114 * @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together 115 * @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num) 116 * @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards 117 * @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or 118 * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! 119 * @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false 120 * @return array of matching rows (the row is an array of the cols) or False 121 */ 122 function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false) 123 { 124 $order_by = explode(',',$order_by); 125 $order_by = explode(' ',$order_by); 126 $sort = $order_by[0]; 127 $order = $order_by[1]; 128 $query = $criteria; 129 $fields = $only_keys ? ($only_keys === true ? $this->contacts_id : $only_keys) : ''; 130 $limit = $need_full_no_count ? 0 : $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; 131 return parent::read($start,$limit,$fields,$query,$filter,$sort,$order); 132 } 133 134 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |