forked from extern/egroupware
fix: vcal missing mendatory fields break palm sync
fix: not working cat filter with not operator
This commit is contained in:
parent
f3ae5cf274
commit
a594417e24
@ -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).')';
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user