From a594417e2440ef45c0f3af739a417086ac1ca933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Sat, 30 Jun 2007 11:20:31 +0000 Subject: [PATCH] fix: vcal missing mendatory fields break palm sync fix: not working cat filter with not operator --- addressbook/inc/class.socontacts_sql.inc.php | 14 ++++++++++---- addressbook/inc/class.vcaladdressbook.inc.php | 17 ++++------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/addressbook/inc/class.socontacts_sql.inc.php b/addressbook/inc/class.socontacts_sql.inc.php index a2f0c828a1..c0d316ca20 100644 --- a/addressbook/inc/class.socontacts_sql.inc.php +++ b/addressbook/inc/class.socontacts_sql.inc.php @@ -243,11 +243,17 @@ class socontacts_sql extends so_sql $owner = isset($filter['owner']) ? $filter['owner'] : (isset($criteria['owner']) ? $criteria['owner'] : null); // fix cat_id filter to search in comma-separated multiple cats and return subcats - if ((int)$filter['cat_id']) + if (($cats = $filter['cat_id'])) { - $filter[] = $this->_cat_filter($filter['cat_id']); + if ($filter['cat_id']{0} == '!') + { + $filter['cat_id'] = substr($filter['cat_id'],1); + $not = 'NOT'; + } + $filter[] = $this->_cat_filter((int)$filter['cat_id'],$not); unset($filter['cat_id']); } + // add filter for read ACL in sql, if user is NOT the owner of the addressbook if (isset($this->grants) && !(isset($filter['owner']) && $filter['owner'] == $GLOBALS['egw_info']['user']['account_id'])) { @@ -349,7 +355,7 @@ class socontacts_sql extends so_sql * @param int $cat_id * @return string sql to filter by given cat */ - function _cat_filter($cat_id) + function _cat_filter($cat_id, $not='') { if (!is_object($GLOBALS['egw']->categories)) { @@ -357,7 +363,7 @@ class socontacts_sql extends so_sql } foreach($GLOBALS['egw']->categories->return_all_children((int)$cat_id) as $cat) { - $cat_filter[] = $this->db->concat("','",cat_id,"','")." LIKE '%,$cat,%'"; + $cat_filter[] = $this->db->concat("','",cat_id,"','")." $not LIKE '%,$cat,%'"; } return '('.implode(' OR ',$cat_filter).')'; } diff --git a/addressbook/inc/class.vcaladdressbook.inc.php b/addressbook/inc/class.vcaladdressbook.inc.php index 130eb4f1d5..6466e215de 100644 --- a/addressbook/inc/class.vcaladdressbook.inc.php +++ b/addressbook/inc/class.vcaladdressbook.inc.php @@ -15,6 +15,7 @@ require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar.php'; class vcaladdressbook extends bocontacts { + /** * import a vard into addressbook * @@ -91,7 +92,8 @@ class vcaladdressbook extends bocontacts } // don't add the entry if it contains only ';' - if(strlen(str_replace(';','',$value)) != 0) { + // exeptions for mendatory fields + if( ( strlen(str_replace(';','',$value)) != 0 ) || in_array($vcardField,array('FN','ORG','N')) ) { $vCard->setAttribute($vcardField, $value); } if(preg_match('/([\000-\012\015\016\020-\037\075])/',$value)) { @@ -103,18 +105,7 @@ class vcaladdressbook extends bocontacts $vCard->setParameter($vcardField, $options); } - // add the full name of the contact; this is a required field - $value = $GLOBALS['egw']->translation->convert($entry['n_fn'], $sysCharSet, 'utf-8'); - $vCard->setAttribute('FN', $value); - $options = array(); - if(preg_match('/([\000-\012\015\016\020-\037\075])/',$value)) { - $options['ENCODING'] = 'QUOTED-PRINTABLE'; - } - if(preg_match('/([\177-\377])/',$value)) { - $options['CHARSET'] = 'UTF-8'; - } - $vCard->setParameter('FN', $options); - + $result = $vCard->exportvCalendar(); return $result;