* CardDAV/Addressbook: fix iOS 8.4 problem allways creating new contacts for admins in accounts addressbook, using now default or personal addressbook

This commit is contained in:
Ralf Becker 2015-07-23 17:40:48 +00:00
parent 2fcde50257
commit f1ba35613c
3 changed files with 22 additions and 8 deletions

View File

@ -7,7 +7,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Joerg Lehrke <jlehrke@noc.de>
* @package addressbook
* @copyright (c) 2005-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-15 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
@ -367,7 +367,8 @@ class addressbook_bo extends addressbook_so
asort($to_sort);
$addressbooks += $to_sort;
}
if (!$preferences['addressbook']['hide_accounts'] && (
if ($required != EGW_ACL_ADD && // do NOT allow to set accounts as default addressbook (AB can add accounts)
!$preferences['addressbook']['hide_accounts'] && (
($grants[0] & $required) == $required ||
$preferences['common']['account_selection'] == 'groupmembers' &&
$this->account_repository != 'ldap' && ($required & EGW_ACL_READ)))
@ -862,6 +863,11 @@ class addressbook_bo extends addressbook_so
// if no owner/addressbook set use the setting of the add_default prefs (if set, otherwise the users personal addressbook)
if (!isset($contact['owner'])) $contact['owner'] = $this->default_addressbook;
if (!isset($contact['private'])) $contact['private'] = (int)$this->default_private;
// do NOT allow to create new accounts via addressbook, they are broken without an account_id
if (!$contact['owner'] && empty($contact['account_id']))
{
$contact['owner'] = $this->default_addressbook ? $this->default_addressbook : $this->user;
}
// allow admins to import contacts with creator / created date set
if (!$contact['creator'] || !$this->is_admin($contact)) $contact['creator'] = $this->user;
if (!$contact['created'] || !$this->is_admin($contact)) $contact['created'] = $this->now_su;

View File

@ -643,12 +643,12 @@ class addressbook_groupdav extends groupdav_handler
$contact['carddav_name'] = $id;
// only set owner, if user is explicitly specified in URL (check via prefix, NOT for /addressbook/) or sync-all-in-one!)
if ($prefix && !in_array('O',$this->home_set_pref))
if ($prefix && !in_array('O',$this->home_set_pref) && $user)
{
$contact['owner'] = $user;
}
// check if default addressbook is synced, if not use (always synced) personal addressbook
elseif($this->bo->default_addressbook && !in_array($this->bo->default_addressbook,$this->home_set_pref))
// check if default addressbook is synced and not accounts, if not use (always synced) personal addressbook
elseif(!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook,$this->home_set_pref))
{
$contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
}
@ -1027,7 +1027,14 @@ class addressbook_groupdav extends groupdav_handler
*/
public function get_grants()
{
return $this->bo->get_grants($this->bo->user);
$grants = $this->bo->get_grants($this->bo->user);
// remove add and delete grants for accounts (for admins too)
// as accounts can not be created as contacts, they eg. need further data
// and admins might not recognice they delete an account incl. its data
if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE);
return $grants;
}
/**

View File

@ -1129,10 +1129,11 @@ window.egw_LAB.wait(function() {
if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact)))
{
if ($contact['owner'] || // regular contact or
empty($contact['account_id']) || // accounts without account_id
// already deleted account (should no longer happen, but needed to allow for cleanup)
$contact['tid'] == addressbook_so::DELETED_TYPE)
{
$Ok = $this->delete($id, $contact['tid'] != addressbook_so::DELETED_TYPE);
$Ok = $this->delete($id, $contact['tid'] != addressbook_so::DELETED_TYPE && $contact['account_id']);
}
// delete single account --> redirect to admin
elseif (count($checked) == 1 && $contact['account_id'])
@ -1641,7 +1642,7 @@ window.egw_LAB.wait(function() {
{
$row['tel_prefered'] = $row[$row['tel_prefer']].$prefer_marker;
}
if (!$row['owner'])
if (!$row['owner'] && $row['account_id'] > 0)
{
$row['class'] .= 'rowAccount rowNoDelete ';
}