Use UID for find_content(); code cleanups

This commit is contained in:
Jörg Lehrke 2009-12-01 10:24:55 +00:00
parent c63a538f13
commit dd92e60180
6 changed files with 83 additions and 56 deletions

View File

@ -705,7 +705,8 @@ class addressbook_bo extends addressbook_so
return false; return false;
} }
// convert categories // convert categories
if (is_array($contact['cat_id'])) { if (is_array($contact['cat_id']))
{
$contact['cat_id'] = implode(',',$contact['cat_id']); $contact['cat_id'] = implode(',',$contact['cat_id']);
} }
// last modified // last modified
@ -1635,9 +1636,25 @@ class addressbook_bo extends addressbook_so
*/ */
function find_contact($contact, $relax=false) function find_contact($contact, $relax=false)
{ {
if (!empty($contact['uid']))
{
// Try the given UID first
Horde::logMessage('Addressbook find UID: '. $contact['uid'],
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$criteria = array ('contact_uid' => $contact['uid']);
if (($found = parent::search($criteria))
&& ($uidmatch = array_shift($found)))
{
return $uidmatch['contact_id'];
}
}
unset($contact['uid']);
if ($contact['id'] && ($found = $this->read($contact['id']))) if ($contact['id'] && ($found = $this->read($contact['id'])))
{ {
// We only do a simple consistency check // We only do a simple consistency check
Horde::logMessage('Addressbook find ID: '. $contact['id'],
__FILE__, __LINE__, PEAR_LOG_DEBUG);
if ((empty($found['n_family']) || $found['n_family'] == $contact['n_family']) if ((empty($found['n_family']) || $found['n_family'] == $contact['n_family'])
&& (empty($found['n_given']) || $found['n_given'] == $contact['n_given']) && (empty($found['n_given']) || $found['n_given'] == $contact['n_given'])
&& (empty($found['org_name']) || $found['org_name'] == $contact['org_name'])) && (empty($found['org_name']) || $found['org_name'] == $contact['org_name']))
@ -1647,12 +1664,10 @@ class addressbook_bo extends addressbook_so
} }
unset($contact['id']); unset($contact['id']);
$columns_to_search = array('contact_id', $columns_to_search = array('n_family', 'n_given', 'n_middle', 'n_prefix', 'n_suffix',
'n_family', 'n_given', 'n_middle', 'n_prefix', 'n_suffix',
'bday', 'org_name', 'org_unit', 'title', 'role', 'bday', 'org_name', 'org_unit', 'title', 'role',
'email', 'email_home'); 'email', 'email_home');
$tolerance_fields = array('contact_id', $tolerance_fields = array('n_middle', 'n_prefix', 'n_suffix',
'n_middle', 'n_prefix', 'n_suffix',
'bday', 'org_unit', 'title', 'role', 'bday', 'org_unit', 'title', 'role',
'email', 'email_home'); 'email', 'email_home');
$addr_one_fields = array('adr_one_street', $addr_one_fields = array('adr_one_street',

View File

@ -82,9 +82,9 @@ class addressbook_vcal extends addressbook_bo
* Set Logging * Set Logging
* *
* @var string * @var string
* off = 0; * off = false;
*/ */
var $log = 0; var $log = false;
var $logfile="/tmp/log-vcard"; var $logfile="/tmp/log-vcard";
/** /**
* Constructor * Constructor
@ -390,8 +390,11 @@ class addressbook_vcal extends addressbook_bo
} }
$result = $vCard->exportvCalendar(); $result = $vCard->exportvCalendar();
if($this->log)error_log(__LINE__.__METHOD__.__FILE__."'$this->productManufacturer','$this->productName'"."\n",3,$this->logfile); if ($this->log)
if($this->log)error_log(__LINE__.__METHOD__.__FILE__."\n".array2string($result)."\n",3,$this->logfile); {
error_log(__LINE__.__METHOD__.__FILE__."'$this->productManufacturer','$this->productName'"."\n",3,$this->logfile);
error_log(__LINE__.__METHOD__.__FILE__."\n".array2string($result)."\n",3,$this->logfile);
}
return $result; return $result;
} }
@ -403,7 +406,7 @@ class addressbook_vcal extends addressbook_bo
{ {
if ($contentID) if ($contentID)
{ {
$contact['contact_id'] = $contentID; $contact['id'] = $contentID;
} }
$result = $this->find_contact($contact, $relax); $result = $this->find_contact($contact, $relax);
} }

View File

@ -216,6 +216,8 @@ class calendar_bo
$this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi $this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite']; $this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
$this->categories = new categories($this->user,'calendar');
} }
/** /**
@ -1314,10 +1316,7 @@ class calendar_bo
static $id2cat = array(); static $id2cat = array();
$cats = array(); $cats = array();
$color = 0; $color = 0;
if (!is_object($this->categories))
{
$this->categories = new categories($this->user,'calendar');
}
foreach(explode(',',$category) as $cat_id) foreach(explode(',',$category) as $cat_id)
{ {
if (!$cat_id) continue; if (!$cat_id) continue;

View File

@ -1135,11 +1135,6 @@ class calendar_boupdate extends calendar_bo
*/ */
function find_or_add_categories($catname_list, $cal_id=-1) function find_or_add_categories($catname_list, $cal_id=-1)
{ {
if (!is_object($this->categories))
{
$this->categories = new categories($this->user,'calendar');
}
if ($cal_id && $cal_id > 0) if ($cal_id && $cal_id > 0)
{ {
// preserve categories without users read access // preserve categories without users read access
@ -1196,11 +1191,6 @@ class calendar_boupdate extends calendar_bo
function get_categories($cat_id_list) function get_categories($cat_id_list)
{ {
if (!is_object($this->categories))
{
$this->categories = new categories($this->user,'calendar');
}
if (!is_array($cat_id_list)) if (!is_array($cat_id_list))
{ {
$cat_id_list = explode(',',$cat_id_list); $cat_id_list = explode(',',$cat_id_list);
@ -1227,10 +1217,15 @@ class calendar_boupdate extends calendar_bo
*/ */
function find_event($event, $relax=false) function find_event($event, $relax=false)
{ {
$query = array( $query = array();
'cal_start='.$event['start'], if (isset($event['start']))
'cal_end='.$event['end'], {
); $query[] = 'cal_start='.$event['start'];
}
if (isset($event['end']))
{
$query[] = 'cal_end='.$event['end'];
}
foreach (array('title', 'location', foreach (array('title', 'location',
'public', 'non_blocking', 'category') as $key) 'public', 'non_blocking', 'category') as $key)
@ -1261,7 +1256,7 @@ class calendar_boupdate extends calendar_bo
{ {
// Do we work with a pseudo exception here? // Do we work with a pseudo exception here?
$match = true; $match = true;
foreach (array('start', 'end', 'title', 'description', 'priority', foreach (array('start', 'end', 'title', 'priority',
'location', 'public', 'non_blocking') as $key) 'location', 'public', 'non_blocking') as $key)
{ {
if (isset($event[$key]) if (isset($event[$key])

View File

@ -24,6 +24,15 @@ class calendar_ical extends calendar_boupdate
*/ */
var $supportedFields; var $supportedFields;
var $recur_days_1_0 = array(
MCAL_M_MONDAY => 'MO',
MCAL_M_TUESDAY => 'TU',
MCAL_M_WEDNESDAY => 'WE',
MCAL_M_THURSDAY => 'TH',
MCAL_M_FRIDAY => 'FR',
MCAL_M_SATURDAY => 'SA',
MCAL_M_SUNDAY => 'SU',
);
/** /**
* @var array $status_egw2ical conversation of the participant status egw => ical * @var array $status_egw2ical conversation of the participant status egw => ical
*/ */
@ -1356,6 +1365,10 @@ class calendar_ical extends calendar_boupdate
} }
break; break;
case 'funambol':
$this->supportedFields = $defaultFields['synthesis'];
break;
// the fallback for SyncML // the fallback for SyncML
default: default:
error_log("Unknown calendar SyncML client: manufacturer='$this->productManufacturer' product='$this->productName'"); error_log("Unknown calendar SyncML client: manufacturer='$this->productManufacturer' product='$this->productName'");

View File

@ -1366,13 +1366,15 @@ class infolog_bo
*/ */
function findVTODO($egwData, $relax=false) function findVTODO($egwData, $relax=false)
{ {
$myfilter = array('col_filter' => array('info_uid'=>$egwData['info_uid'])) ; if (!empty($egwData['info_uid']))
if ($egwData['info_uid'] {
&& ($found = $this->search($myfilter)) $filter = array('col_filter' => array('info_uid' => $egwData['info_uid']));
if (($found = $this->search($filter))
&& ($uidmatch = array_shift($found))) && ($uidmatch = array_shift($found)))
{ {
return $uidmatch['info_id']; return $uidmatch['info_id'];
}; }
}
unset($egwData['info_uid']); unset($egwData['info_uid']);
$filter = array(); $filter = array();