forked from extern/egroupware
Use UID for find_content(); code cleanups
This commit is contained in:
parent
c63a538f13
commit
dd92e60180
@ -705,7 +705,8 @@ class addressbook_bo extends addressbook_so
|
||||
return false;
|
||||
}
|
||||
// convert categories
|
||||
if (is_array($contact['cat_id'])) {
|
||||
if (is_array($contact['cat_id']))
|
||||
{
|
||||
$contact['cat_id'] = implode(',',$contact['cat_id']);
|
||||
}
|
||||
// last modified
|
||||
@ -1635,9 +1636,25 @@ class addressbook_bo extends addressbook_so
|
||||
*/
|
||||
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'])))
|
||||
{
|
||||
// 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'])
|
||||
&& (empty($found['n_given']) || $found['n_given'] == $contact['n_given'])
|
||||
&& (empty($found['org_name']) || $found['org_name'] == $contact['org_name']))
|
||||
@ -1647,12 +1664,10 @@ class addressbook_bo extends addressbook_so
|
||||
}
|
||||
unset($contact['id']);
|
||||
|
||||
$columns_to_search = array('contact_id',
|
||||
'n_family', 'n_given', 'n_middle', 'n_prefix', 'n_suffix',
|
||||
$columns_to_search = array('n_family', 'n_given', 'n_middle', 'n_prefix', 'n_suffix',
|
||||
'bday', 'org_name', 'org_unit', 'title', 'role',
|
||||
'email', 'email_home');
|
||||
$tolerance_fields = array('contact_id',
|
||||
'n_middle', 'n_prefix', 'n_suffix',
|
||||
$tolerance_fields = array('n_middle', 'n_prefix', 'n_suffix',
|
||||
'bday', 'org_unit', 'title', 'role',
|
||||
'email', 'email_home');
|
||||
$addr_one_fields = array('adr_one_street',
|
||||
|
@ -82,9 +82,9 @@ class addressbook_vcal extends addressbook_bo
|
||||
* Set Logging
|
||||
*
|
||||
* @var string
|
||||
* off = 0;
|
||||
* off = false;
|
||||
*/
|
||||
var $log = 0;
|
||||
var $log = false;
|
||||
var $logfile="/tmp/log-vcard";
|
||||
/**
|
||||
* Constructor
|
||||
@ -390,8 +390,11 @@ class addressbook_vcal extends addressbook_bo
|
||||
}
|
||||
|
||||
$result = $vCard->exportvCalendar();
|
||||
if($this->log)error_log(__LINE__.__METHOD__.__FILE__."'$this->productManufacturer','$this->productName'"."\n",3,$this->logfile);
|
||||
if($this->log)error_log(__LINE__.__METHOD__.__FILE__."\n".array2string($result)."\n",3,$this->logfile);
|
||||
if ($this->log)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -403,7 +406,7 @@ class addressbook_vcal extends addressbook_bo
|
||||
{
|
||||
if ($contentID)
|
||||
{
|
||||
$contact['contact_id'] = $contentID;
|
||||
$contact['id'] = $contentID;
|
||||
}
|
||||
$result = $this->find_contact($contact, $relax);
|
||||
}
|
||||
|
@ -216,6 +216,8 @@ class calendar_bo
|
||||
$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->categories = new categories($this->user,'calendar');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1314,10 +1316,7 @@ class calendar_bo
|
||||
static $id2cat = array();
|
||||
$cats = array();
|
||||
$color = 0;
|
||||
if (!is_object($this->categories))
|
||||
{
|
||||
$this->categories = new categories($this->user,'calendar');
|
||||
}
|
||||
|
||||
foreach(explode(',',$category) as $cat_id)
|
||||
{
|
||||
if (!$cat_id) continue;
|
||||
|
@ -1135,22 +1135,17 @@ class calendar_boupdate extends calendar_bo
|
||||
*/
|
||||
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
|
||||
$old_event = $this->read($cal_id);
|
||||
$old_categories = explode(',',$old_event['category']);
|
||||
$old_cats_preserve = array();
|
||||
if(is_array($old_categories) && count($old_categories) > 0)
|
||||
if (is_array($old_categories) && count($old_categories) > 0)
|
||||
{
|
||||
foreach($old_categories as $cat_id)
|
||||
foreach ($old_categories as $cat_id)
|
||||
{
|
||||
if(!$this->categories->check_perms(EGW_ACL_READ, $cat_id))
|
||||
if (!$this->categories->check_perms(EGW_ACL_READ, $cat_id))
|
||||
{
|
||||
$old_cats_preserve[] = $cat_id;
|
||||
}
|
||||
@ -1159,7 +1154,7 @@ class calendar_boupdate extends calendar_bo
|
||||
}
|
||||
|
||||
$cat_id_list = array();
|
||||
foreach($catname_list as $cat_name)
|
||||
foreach ($catname_list as $cat_name)
|
||||
{
|
||||
$cat_name = trim($cat_name);
|
||||
$cat_id = $this->categories->name2id($cat_name, 'X-');
|
||||
@ -1180,7 +1175,7 @@ class calendar_boupdate extends calendar_bo
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($old_cats_preserve) && count($old_cats_preserve) > 0)
|
||||
if (is_array($old_cats_preserve) && count($old_cats_preserve) > 0)
|
||||
{
|
||||
$cat_id_list = array_merge($cat_id_list, $old_cats_preserve);
|
||||
}
|
||||
@ -1196,17 +1191,12 @@ class calendar_boupdate extends calendar_bo
|
||||
|
||||
function get_categories($cat_id_list)
|
||||
{
|
||||
if (!is_object($this->categories))
|
||||
{
|
||||
$this->categories = new categories($this->user,'calendar');
|
||||
}
|
||||
|
||||
if (!is_array($cat_id_list))
|
||||
{
|
||||
$cat_id_list = explode(',',$cat_id_list);
|
||||
}
|
||||
$cat_list = array();
|
||||
foreach($cat_id_list as $cat_id)
|
||||
foreach ($cat_id_list as $cat_id)
|
||||
{
|
||||
if ($cat_id && $this->categories->check_perms(EGW_ACL_READ, $cat_id) &&
|
||||
($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--')
|
||||
@ -1227,10 +1217,15 @@ class calendar_boupdate extends calendar_bo
|
||||
*/
|
||||
function find_event($event, $relax=false)
|
||||
{
|
||||
$query = array(
|
||||
'cal_start='.$event['start'],
|
||||
'cal_end='.$event['end'],
|
||||
);
|
||||
$query = array();
|
||||
if (isset($event['start']))
|
||||
{
|
||||
$query[] = 'cal_start='.$event['start'];
|
||||
}
|
||||
if (isset($event['end']))
|
||||
{
|
||||
$query[] = 'cal_end='.$event['end'];
|
||||
}
|
||||
|
||||
foreach (array('title', 'location',
|
||||
'public', 'non_blocking', 'category') as $key)
|
||||
@ -1246,7 +1241,7 @@ class calendar_boupdate extends calendar_bo
|
||||
$query['cal_uid'] = $event['uid'];
|
||||
$query['cal_recurrence'] = $event['recurrence'];
|
||||
|
||||
if($foundEvents = parent::search(array(
|
||||
if ($foundEvents = parent::search(array(
|
||||
'query' => $query,
|
||||
)))
|
||||
{
|
||||
@ -1261,7 +1256,7 @@ class calendar_boupdate extends calendar_bo
|
||||
{
|
||||
// Do we work with a pseudo exception here?
|
||||
$match = true;
|
||||
foreach (array('start', 'end', 'title', 'description', 'priority',
|
||||
foreach (array('start', 'end', 'title', 'priority',
|
||||
'location', 'public', 'non_blocking') as $key)
|
||||
{
|
||||
if (isset($event[$key])
|
||||
|
@ -24,6 +24,15 @@ class calendar_ical extends calendar_boupdate
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -1356,6 +1365,10 @@ class calendar_ical extends calendar_boupdate
|
||||
}
|
||||
break;
|
||||
|
||||
case 'funambol':
|
||||
$this->supportedFields = $defaultFields['synthesis'];
|
||||
break;
|
||||
|
||||
// the fallback for SyncML
|
||||
default:
|
||||
error_log("Unknown calendar SyncML client: manufacturer='$this->productManufacturer' product='$this->productName'");
|
||||
|
@ -1366,13 +1366,15 @@ class infolog_bo
|
||||
*/
|
||||
function findVTODO($egwData, $relax=false)
|
||||
{
|
||||
$myfilter = array('col_filter' => array('info_uid'=>$egwData['info_uid'])) ;
|
||||
if ($egwData['info_uid']
|
||||
&& ($found = $this->search($myfilter))
|
||||
if (!empty($egwData['info_uid']))
|
||||
{
|
||||
$filter = array('col_filter' => array('info_uid' => $egwData['info_uid']));
|
||||
if (($found = $this->search($filter))
|
||||
&& ($uidmatch = array_shift($found)))
|
||||
{
|
||||
return $uidmatch['info_id'];
|
||||
};
|
||||
}
|
||||
}
|
||||
unset($egwData['info_uid']);
|
||||
|
||||
$filter = array();
|
||||
|
Loading…
Reference in New Issue
Block a user