forked from extern/egroupware
Use UID for find_content(); code cleanups
This commit is contained in:
parent
a1ee7d5cbf
commit
54fd41a16a
@ -119,6 +119,12 @@ class addressbook_bo extends addressbook_so
|
||||
* @var boolean
|
||||
*/
|
||||
var $default_private;
|
||||
/**
|
||||
* Categories object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
var $categories;
|
||||
|
||||
function __construct($contact_app='addressbook')
|
||||
{
|
||||
@ -245,6 +251,7 @@ class addressbook_bo extends addressbook_so
|
||||
{
|
||||
$this->org_fields = unserialize($GLOBALS['egw_info']['server']['org_fileds_to_update']);
|
||||
}
|
||||
$this->categories = new categories($this->user,'addressbook');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1418,8 +1425,6 @@ class addressbook_bo extends addressbook_so
|
||||
return $adr_format;
|
||||
}
|
||||
|
||||
var $categories;
|
||||
|
||||
/**
|
||||
* Find existing categories in database by name or add categories that do not exist yet
|
||||
* currently used for vcard import
|
||||
@ -1431,11 +1436,6 @@ class addressbook_bo extends addressbook_so
|
||||
*/
|
||||
function find_or_add_categories($catname_list, $contact_id=null)
|
||||
{
|
||||
if (!is_object($this->categories))
|
||||
{
|
||||
$this->categories = new categories($this->owner,'addressbook');
|
||||
}
|
||||
|
||||
if($contact_id && $contact_id > 0)
|
||||
{
|
||||
// preserve categories without users read access
|
||||
@ -1549,9 +1549,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']))
|
||||
@ -1561,12 +1577,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);
|
||||
}
|
||||
|
@ -163,6 +163,12 @@ class calendar_bo
|
||||
* @var egw_datetime
|
||||
*/
|
||||
var $datetime;
|
||||
/**
|
||||
* Instance of the categories class
|
||||
*
|
||||
* @var $categories
|
||||
*/
|
||||
var $categories;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -209,6 +215,8 @@ class calendar_bo
|
||||
//echo "registered resources="; _debug_array($this->resources);
|
||||
|
||||
$this->config = config::read('calendar');
|
||||
|
||||
$this->categories = new categories($this->user,'calendar');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1567,17 +1575,14 @@ class calendar_bo
|
||||
static $id2cat = array();
|
||||
$cats = array();
|
||||
$color = 0;
|
||||
if (!is_object($this->cats))
|
||||
{
|
||||
$this->cats = CreateObject('phpgwapi.categories','','calendar');
|
||||
}
|
||||
|
||||
foreach(explode(',',$category) as $cat_id)
|
||||
{
|
||||
if (!$cat_id) continue;
|
||||
|
||||
if (!isset($id2cat[$cat_id]))
|
||||
{
|
||||
list($id2cat[$cat_id]) = $this->cats->return_single($cat_id);
|
||||
list($id2cat[$cat_id]) = $this->categories->return_single($cat_id);
|
||||
$id2cat[$cat_id]['data'] = unserialize($id2cat[$cat_id]['data']);
|
||||
}
|
||||
$cat = $id2cat[$cat_id];
|
||||
|
@ -1050,8 +1050,6 @@ class calendar_boupdate extends calendar_bo
|
||||
return $this->so->delete_alarm($id, $this->now_su);
|
||||
}
|
||||
|
||||
var $categories;
|
||||
|
||||
/**
|
||||
* Find existing categories in database by name or add categories that do not exist yet
|
||||
* currently used for ical/sif import
|
||||
@ -1063,11 +1061,6 @@ 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)
|
||||
{
|
||||
// preserve categories without users read access
|
||||
@ -1124,11 +1117,6 @@ 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);
|
||||
@ -1155,10 +1143,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)
|
||||
@ -1189,7 +1182,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])
|
||||
|
@ -1425,6 +1425,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'");
|
||||
|
@ -704,7 +704,8 @@ class infolog_bo
|
||||
);
|
||||
}
|
||||
$values['info_id'] = $info_id;
|
||||
|
||||
// if the info responbsible array is not passed, fetch it from old.
|
||||
if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible'];
|
||||
if (!is_array($values['info_responsible'])) // this should not happen, bug it does ;-)
|
||||
{
|
||||
$values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array();
|
||||
@ -723,6 +724,11 @@ class infolog_bo
|
||||
{
|
||||
$this->tracking = new infolog_tracking($this);
|
||||
}
|
||||
|
||||
if (($missing_fields = array_diff_key($old,$values)))
|
||||
{
|
||||
$values = array_merge($values,$missing_fields);
|
||||
}
|
||||
$this->tracking->track($values,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted');
|
||||
}
|
||||
if ($info_from_set) $values['info_from'] = '';
|
||||
@ -1082,7 +1088,7 @@ class infolog_bo
|
||||
{
|
||||
$this->categories = new categories($this->user,'infolog');
|
||||
}
|
||||
|
||||
|
||||
if($info_id && $info_id > 0)
|
||||
{
|
||||
// preserve categories without users read access
|
||||
@ -1106,7 +1112,7 @@ class infolog_bo
|
||||
{
|
||||
$cat_name = trim($cat_name);
|
||||
$cat_id = $this->categories->name2id($cat_name, 'X-');
|
||||
|
||||
|
||||
if (!$cat_id)
|
||||
{
|
||||
// some SyncML clients (mostly phones) add an X- to the category names
|
||||
@ -1122,7 +1128,7 @@ class infolog_bo
|
||||
$cat_id_list[] = $cat_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(is_array($old_cats_preserve) && count($old_cats_preserve) > 0)
|
||||
{
|
||||
$cat_id_list = array_merge($old_cats_preserve, $cat_id_list);
|
||||
@ -1159,7 +1165,7 @@ class infolog_bo
|
||||
$cat_list = array();
|
||||
foreach($cat_id_list as $cat_id)
|
||||
{
|
||||
if ($cat_id && $this->categories->check_perms(EGW_ACL_READ, $cat_id) &&
|
||||
if ($cat_id && $this->categories->check_perms(EGW_ACL_READ, $cat_id) &&
|
||||
($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--')
|
||||
{
|
||||
$cat_list[] = $cat_name;
|
||||
@ -1360,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))
|
||||
&& ($uidmatch = array_shift($found)))
|
||||
if (!empty($egwData['info_uid']))
|
||||
{
|
||||
return $uidmatch['info_id'];
|
||||
};
|
||||
$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