Fix PHP warning when adding contact to a group (Bug #1989)

This commit is contained in:
Aleksander Machniak 2013-07-01 12:04:56 +02:00
parent cab58ba233
commit bba45ce59d
2 changed files with 16 additions and 11 deletions

View file

@ -821,13 +821,20 @@ class rcube_kolab_contacts extends rcube_addressbook
foreach ($ids as $contact_id) { foreach ($ids as $contact_id) {
$uid = $this->id2uid($contact_id); $uid = $this->id2uid($contact_id);
if ($contact = $this->storagefolder->get_object($uid)) { if ($contact = $this->storagefolder->get_object($uid)) {
foreach ($this->get_col_values('email', $contact, true) as $email) $email = '';
break; if (empty($uid)) {
foreach ($contact['email'] as $email) {
if (is_array($email)) {
$email = $email['address'];
}
break;
}
}
$list['member'][] = array( $list['member'][] = array(
'uid' => $uid, 'uid' => $uid,
'email' => $email, 'email' => $email,
'name' => self::compose_display_name($contact), 'name' => self::compose_display_name($contact),
); );
$this->groupmembers[$contact_id][] = $gid; $this->groupmembers[$contact_id][] = $gid;
$added++; $added++;
@ -835,7 +842,7 @@ class rcube_kolab_contacts extends rcube_addressbook
else if (strpos($uid, 'mailto:') === 0 && ($contact = $this->contacts[$contact_id])) { else if (strpos($uid, 'mailto:') === 0 && ($contact = $this->contacts[$contact_id])) {
$list['member'][] = array( $list['member'][] = array(
'email' => $contact['email'], 'email' => $contact['email'],
'name' => $contact['name'], 'name' => $contact['name'],
); );
$this->groupmembers[$contact_id][] = $gid; $this->groupmembers[$contact_id][] = $gid;
$added++; $added++;
@ -1096,7 +1103,7 @@ class rcube_kolab_contacts extends rcube_addressbook
else if (!$contact['uid'] && $old['uid']) else if (!$contact['uid'] && $old['uid'])
$contact['uid'] = $old['uid']; $contact['uid'] = $old['uid'];
$contact['im'] = array_filter($this->get_col_values('im', $contact, true)); $contact['im'] = array_filter($this->get_col_values('im', $contact, true));
// convert email, website, phone values // convert email, website, phone values
foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) { foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) {

View file

@ -44,7 +44,6 @@ class kolab_format_distributionlist extends kolab_format
$this->obj->setName($object['name']); $this->obj->setName($object['name']);
$seen = array();
$members = new vectorcontactref; $members = new vectorcontactref;
foreach ((array)$object['member'] as $member) { foreach ((array)$object['member'] as $member) {
if ($member['uid']) if ($member['uid'])
@ -56,7 +55,6 @@ class kolab_format_distributionlist extends kolab_format
$m->setName($member['name']); $m->setName($member['name']);
$members->push($m); $members->push($m);
$seen[$member['email']]++;
} }
$this->obj->setMembers($members); $this->obj->setMembers($members);
@ -100,11 +98,11 @@ class kolab_format_distributionlist extends kolab_format
$members = $this->obj->members(); $members = $this->obj->members();
for ($i=0; $i < $members->size(); $i++) { for ($i=0; $i < $members->size(); $i++) {
$member = $members->get($i); $member = $members->get($i);
# if ($member->type() == ContactReference::UidReference && ($uid = $member->uid())) // if ($member->type() == ContactReference::UidReference && ($uid = $member->uid()))
$object['member'][] = array( $object['member'][] = array(
'uid' => $member->uid(), 'uid' => $member->uid(),
'email' => $member->email(), 'email' => $member->email(),
'name' => $member->name(), 'name' => $member->name(),
); );
} }