1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

Contacts: Port fixes from master/stable5

This commit is contained in:
Thomas Tanghus 2013-04-07 16:47:28 +02:00
parent 1589866f8c
commit f0e6472d73
3 changed files with 25 additions and 5 deletions

View File

@ -829,9 +829,12 @@ OC.Contacts = OC.Contacts || {
*
* @param object $list A jquery object of an unordered list
* @param object book An object with the properties 'id', 'name' and 'permissions'.
* @param bool add Whether the address book list should be updated.
*/
var appendAddressBook = function($list, book) {
self.contacts.setAddressbook(book);
var appendAddressBook = function($list, book, add) {
if(add) {
self.contacts.setAddressbook(book);
}
var $li = self.$addressbookTmpl.octemplate({
id: book.id,
permissions: book.permissions,
@ -911,7 +914,7 @@ OC.Contacts = OC.Contacts || {
} else {
var book = response.data;
var $list = self.$settings.find('[data-id="addressbooks"]').next('ul');
appendAddressBook($list, book);
appendAddressBook($list, book, true);
}
$addinput.removeClass('loading');
$addAddressbookPart.find('button input').prop('disabled', false);
@ -949,7 +952,7 @@ OC.Contacts = OC.Contacts || {
$list.empty();
$.each(self.contacts.addressbooks, function(id, book) {
appendAddressBook($list, book);
appendAddressBook($list, book, false);
});
if(typeof OC.Share !== 'undefined') {
OC.Share.loadIcons('addressbook');

View File

@ -407,6 +407,10 @@ OC.Contacts = OC.Contacts || {};
var checksum = self.checksumFor(obj);
var value = self.valueFor(obj);
var parameters = self.parametersFor(obj);
if(parameters['TYPE'] && parameters['TYPE'].indexOf('PREF') !== -1) {
parameters['PREF'] = 1;
parameters['TYPE'].splice(parameters['TYPE'].indexOf('PREF', 1));
}
if(checksum && checksum !== 'new') {
self.pushToUndo({
action:'save',

View File

@ -76,6 +76,19 @@ class AddressBook extends \Sabre_CardDAV_AddressBook {
$deleteprincipal = $this->getOwner();
$uid = $this->carddavBackend->userIDByPrincipal($this->getOwner());
$readWriteACL = array(
array(
'privilege' => '{DAV:}read',
'principal' => 'principals/' . OCP\User::getUser(),
'protected' => true,
),
array(
'privilege' => '{DAV:}write',
'principal' => 'principals/' . OCP\User::getUser(),
'protected' => true,
),
);
if($uid != \OCP\USER::getUser()) {
$sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']);
if($sharedAddressbook) {
@ -83,7 +96,7 @@ class AddressBook extends \Sabre_CardDAV_AddressBook {
&& ($sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE)
&& ($sharedAddressbook['permissions'] & OCP\PERMISSION_DELETE)
) {
return parent::getACL();
return $readWriteACL;
}
if ($sharedAddressbook['permissions'] & OCP\PERMISSION_CREATE) {
$createprincipal = 'principals/' . OCP\USER::getUser();